OSDN Git Service

instantupdate auto repairs repos
[instantos/instantOS.git] / programs / instantclipmenu
1 #!/usr/bin/env bash
2
3 # simple clipmenu wrapper
4
5 : "${CM_DIR="${XDG_RUNTIME_DIR-"${TMPDIR-/tmp}"}"}"
6 major_version=6
7
8 enableclipmenu() {
9     if ! imenu -c "enable clipboard management?"; then
10         exit
11     fi
12     iconf -i clipmanager 1
13     instantinstall clipmenu
14     sleep 0.2
15     pgrep -f clipmenud || clipmenud &
16     notify-send "enabling clipboard management, loading..."
17     sleep 2
18     echo "this menu will show recent clipboard entries" >"$cache_file"
19     echo "click on an entry to restore its contents" >>"$cache_file"
20 }
21
22 shopt -s nullglob
23
24 cache_dir=$CM_DIR/clipmenu.$major_version.$USER
25 cache_file=$cache_dir/line_cache
26
27 if [ "$1" = "delete" ]; then
28     if imenu -c "clear clipboard cache?"; then
29         echo "clearing cache"
30         echo "cache $cache_file"
31         echo "cleared" >"$cache_file"
32         exit
33     fi
34 fi
35
36 [ -e "$cache_file" ] || enableclipmenu
37 CM_LAUNCHER=instantmenu clipmenu -p "    " -q 'clipboard manager' -h -1 -lc "instantclipmenu delete"