-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathssuspend
executable file
·45 lines (40 loc) · 1.42 KB
/
ssuspend
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
#!/usr/bin/env fish
# ssuspend - "Screen suspend". Simply turns off your monitor(s).
# 'ssuspend on' to unsuspend.
set -- script "$(path basename (status filename))"
argparse -n $script 'h/help' -- $argv
if set -q _flag_h
echo "$script - \"Screen suspend\". Simply turns off your monitor(s)."
echo "Usage: $script [arguments] [on/off]"
echo
echo " -h/--help - Print help and exit."
exit
end
if not set -q argv[1]; or contains -- "$argv[1]" "off" "0"
# per https://wiki.archlinux.org/title/Display_Power_Management_Signaling :
# "Note that DPMS was developed for CRT monitors, and on LCD displays, there is normally no difference between the standby, suspend and off modes."
# "off" is used as per the suggestion in xscreensaver-command's man page.
set action 'off'
else if contains -- "$argv[1]" "on" "1"
set action 'on'
# else if contains -- "$argv[1]" "toggle"
# set action 'toggle'
else
warn -t "$script" -l 'error' "Unknown action: \"$argv[1]\"."
exit 1
end
if set -q WAYLAND_DISPLAY
if test "$XDG_CURRENT_DESKTOP" = 'sway'
swaymsg "output * power $action"
else
warn -t "$script" -l 'error' "Unsupported Wayland desktop: \"$XDG_CURRENT_DESKTOP\"."
exit 1
end
else if set -q DISPLAY
xset dpms force $action
else if test "$TERM" = 'linux'
vbetool dpms $action
else
warn -t "$script" -l 'error' "Unknown/unsupported display manager."
exit 1
end