-
-
Notifications
You must be signed in to change notification settings - Fork 20
/
i3-resurrect-dmenu
executable file
·57 lines (49 loc) · 1.01 KB
/
i3-resurrect-dmenu
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/usr/bin/env bash
ACTIONS=("Restore" "Save" "Delete")
TARGETS=("Both" "Programs" "Layout")
DMENU="dmenu -i"
prompt="i3-resurrect"
action=$(printf "%s\n" ${ACTIONS[@]} | $DMENU -p $prompt)
case $action in
Save)
command="i3-resurrect save --swallow=class,instance,title -p"
;;
Restore)
command="i3-resurrect restore -p"
;;
Delete)
command="i3-resurrect rm -p"
;;
*)
echo "Invalid action"
exit 1
;;
esac
prompt="Profile"
profile=$(i3-resurrect ls profiles | awk '{$NF=""; $1=""; print $0}' | uniq | $DMENU -p "$prompt" | xargs)
if [[ "$profile" == "" ]]; then
echo "Invalid profile"
exit 1
fi
prompt="Target"
target=$(printf "%s\n" ${TARGETS[@]} | $DMENU -p $prompt)
case $target in
Programs)
target_option="--programs-only"
;;
Layout)
target_option="--layout-only"
;;
Both)
target_option=""
;;
*)
echo "Invalid target"
exit 1
;;
esac
if [[ -n "$target_option" ]]; then
$command "$profile" "$target_option"
else
$command "$profile"
fi