File: save_via_windows.sh

package info (click to toggle)
raysession 0.17.4-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 19,196 kB
  • sloc: python: 44,463; sh: 1,538; makefile: 213; xml: 86
file content (36 lines) | stat: -rw-r--r-- 829 bytes parent folder | download
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
#!/bin/sh

for executable in xdotool; do
    if ! command -v "$executable" >/dev/null; then
        exit
    fi
done

[ -n "$WAYLAND_DISPLAY" ] && exit

start_win=$(xdotool getactivewindow)
focus_changed=false

for client_id in $(ray_control list_clients no_save_level); do
    executable_line=$(ray_control client "$client_id" get_properties | grep ^executable:)
    executable=$(basename "${executable_line#*:}")

    [ -n "$executable" ] || continue

    wins=$(xdotool search --class "$executable")

    for windowid in $wins; do
        if [ "$(xdotool getwindowname "$windowid")" != "*" ]; then
            focus_changed=true
            xdotool windowactivate "$windowid"
            xdotool key ctrl+s
            break
        fi
    done
done

if $focus_changed; then
    xdotool windowactivate "$start_win"
fi

exit 0