-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscratchpad-old
executable file
·49 lines (43 loc) · 1.86 KB
/
scratchpad-old
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
#! /bin/sh
if [ $# = 0 ]; then
cat <<EOF
Usage: $(basename "${0}") process_name [executable_name] [--take-first]
process_name As recognized by 'xdo' command
executable_name As used for launching from terminal
--take-first In case 'xdo' returns multiple process IDs
EOF
exit 0
fi
# Get id of process by class name
id=$(xdotool search --classname "${1}")
# Show a blurred background
if [ -f ~/.cache/scratchpad-blur.lock ]; then
kill `cat ~/.cache/scratchpad-blur.lock`
rm ~/.cache/scratchpad-blur.lock
state=on
else
(echo 'exec("""\nfrom Xlib import X, display, Xatom\ndisplay = display.Display()\nscreen = display.screen()\nwindow = screen.root.create_window(\n 0, 0, 1920, 1080, 1,\n screen.root_depth,\n background_pixel=screen.black_pixel\n)\nwindow.set_wm_class("blur", "blur")\nwindow.change_property(display.get_atom("_NET_WM_WINDOW_OPACITY"), Xatom.CARDINAL,32,[0x20000000])\nwindow.change_property(display.get_atom("_NET_WM_STATE"), Xatom.ATOM,32,[display.get_atom("_NET_WM_STATE_FULLSCREEN"),display.get_atom("_NET_WM_STATE_STICKY")])\nwindow.map()\nwhile True: display.next_event()\n""")' | python - & p=$!; echo $p > ~/.cache/scratchpad-blur.lock; wait $p; rm ~/.cache/scratchpad-blur.lock ) &
state=off
fi
executable=${2}
shift
while [ -n "${1}" ]; do
case ${1} in
--take-first)
id=$(head -1 <<<"${id}" | cut -f1 -d' ')
;;
*)
executable=${1}
;;
esac
shift
done
if [ -z "${id}" ]; then
${executable}
else
while read -r instance; do
#bspc node "${instance}" --flag hidden --to-monitor focused --focus
#bspc node "${instance}" --flag hidden --flag sticky=on --layer above --to-monitor focused --focus -t floating
bspc node "${instance}" --flag hidden=${state} --to-monitor focused --focus --flag sticky=on -t floating --layer above
done <<<"${id}"
fi