浏览代码

Revamp eedmenu to be more flexible

eedmenu now does not use special parameter for ini reading.  INI can be
used but we expect user to send it on STDIN (probably using eeini) just
as any other (delimited) file.
Alois Mahdal 10 年前
父节点
当前提交
3312ab6ece
共有 1 个文件被更改,包括 9 次插入17 次删除
  1. 9
    17
      bin/eedmenu.in

+ 9
- 17
bin/eedmenu.in 查看文件

@@ -7,24 +7,21 @@ ffoo import ini
7 7
 FFOO_INI_PATH="__FFOO_INI_PATH__"
8 8
 
9 9
 usage() {
10
-    usage_is "[-l|--lines] [-d|--delim] [-e|--read-eeini]"
10
+    usage_is "[-l|--lines NUM] [-s|--split CHAR]"
11 11
 }
12 12
 
13 13
 numbered=false
14 14
 lines=10
15
-maybe_cut=cat
16
-maybe_read_eeini=cat
15
+maybe_split=cat
17 16
 
18 17
 while true; do case $1 in
19
-    -l|--lines)         lines=$2;                   shift 2 ;;
20
-    -d|--delim)         delim=$2;                   shift 2 ;;
21
-    -e|--read-eeini)    read_eeini=$2; delim='=';   shift 2 ;;
22
-    "")                 break                               ;;
18
+    -l|--lines)         lines=$2; shift 2 ;;
19
+    -s|--split)         delim=$2; shift 2 ;;
20
+    "")                 break             ;;
23 21
     *)  usage
24 22
 esac done
25 23
 
26
-test -n "$delim"        && maybe_cut=do_cut
27
-test -n "$read_eeini"   && maybe_read_eeini=do_read_eeini
24
+test -n "$delim"        && maybe_split=do_split
28 25
 
29 26
 host=$(hostname -s)
30 27
 nb="$(iniread -p style.color.nbg)"
@@ -40,14 +37,9 @@ arg_sf="${sf:+-sf $sf}"
40 37
 arg_fn="${fn:+-fn $fn}"
41 38
 style="$arg_nb $arg_nf $arg_sb $arg_sf $arg_fn"
42 39
 
43
-do_cut() {
40
+do_split() {
44 41
     cut -d$delim -f2-
45 42
 }
46 43
 
47
-do_read_eeini() {
48
-    iniread $read_eeini
49
-}
50
-
51
-$maybe_read_eeini \
52
-  | dmenu -l $lines $style \
53
-  | $maybe_cut
44
+dmenu -l $lines $style \
45
+  | $maybe_split