-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathcaffeine
More file actions
executable file
·67 lines (52 loc) · 1.54 KB
/
caffeine
File metadata and controls
executable file
·67 lines (52 loc) · 1.54 KB
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
58
59
60
61
62
63
64
65
66
67
#!/usr/bin/env cached-nix-shell
#! nix-shell nix/shell/xonsh.nix -i xonsh
"""
Choose the desktop theme and applications' appearance based on that.
Usage:
{program} [on | off | status]
{program} (-h | --help)
{program} --version
Options:
-h --help Show this screen.
-v --version Show version.
"""
from docopt import docopt
import os
import sys
$RED="\033[1;31m"
$YELLOW="\033[1;33m"
$GREEN="\033[1;32m"
$BLUE="\033[1;34m"
$RESET="\033[0m"
# $RAISE_SUBPROC_ERROR = True
def pick_status_interactively():
return $(gum choose "on" "off").strip()
def gsettings_get_caffeine_status():
return $(gsettings get org.gnome.shell.extensions.caffeine cli-toggle).strip().lower()
def get_caffeine_status():
match gsettings_get_caffeine_status():
case "true":
return "on"
case "false":
return "off"
def set_caffeine(status):
match status:
case "on":
gsettings set org.gnome.shell.extensions.caffeine cli-toggle true
case "off":
gsettings set org.gnome.shell.extensions.caffeine cli-toggle false
echo -e @(f"caffeine is {status}") "$GREEN✓$RESET"
def main(args):
if args["on"]:
set_caffeine("on")
elif args["off"]:
set_caffeine("off")
elif args["status"]:
print(get_caffeine_status())
else:
status = pick_status_interactively()
set_caffeine(status)
if __name__ == "__main__":
arguments = docopt(__doc__.format(program=__file__), version=f'{os.path.basename(__file__)} v0.1.0')
main(arguments)
# vim: ft=python