summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2023-02-12 21:58:56 +0000
committerAnton Khirnov <anton@khirnov.net>2023-02-12 21:59:40 +0000
commit8cb8e431d3a54ca056dd3074ef286361a2dd9c87 (patch)
treee30f458cc45d30cd0bddad7bbe26f862bdbffd01
parent974036808d41e6805902f9b8fcb3e39773bbb65d (diff)
bin/Xsession: drop brightness_monitor
It does not work as it needs a notification daemon to be running when the script is started, which is not true at that point in xsession. This will be handled in the window manager instead.
-rwxr-xr-xbin/brightness_monitor40
-rw-r--r--desktop.conf.yaml3
-rw-r--r--dotfiles/Xsession5
3 files changed, 2 insertions, 46 deletions
diff --git a/bin/brightness_monitor b/bin/brightness_monitor
deleted file mode 100755
index a8617e0..0000000
--- a/bin/brightness_monitor
+++ /dev/null
@@ -1,40 +0,0 @@
-#!/usr/bin/python3
-
-import notify2
-import os
-import subprocess
-import sys
-
-if len(sys.argv) < 2:
- sys.stdout.write('Usage: %s /sys/.../<backlight dir>/\n')
- sys.exit(0)
-
-path = sys.argv[1]
-
-with open(os.path.join(path, 'max_brightness'), 'r') as f:
- brightness_max = float(f.read().strip())
-
-notify2.init(os.path.basename(sys.argv[0]))
-
-notification = notify2.Notification('Brightness')
-
-inotify_cmd = ['inotifywait', '--monitor', '--event=close_write',
- os.path.join(path, 'brightness')]
-
-child = subprocess.Popen(inotify_cmd, stdout = subprocess.PIPE, bufsize = 0)
-
-while True:
- # wait for updates
- child.stdout.read(4096)
- if child.poll() is not None:
- notification.message = 'inotify monitor has terminated'
- notification.set_urgency(notify2.URGENCY_CRITICAL)
- notification.show()
- sys.stderr.write(notification.message + '\n')
- break
-
- with open(os.path.join(path, 'brightness'), 'r') as f:
- brightness = float(f.read().strip())
-
- notification.message = '%d%%' % (100 * brightness / brightness_max)
- notification.show()
diff --git a/desktop.conf.yaml b/desktop.conf.yaml
index 1305680..234dd73 100644
--- a/desktop.conf.yaml
+++ b/desktop.conf.yaml
@@ -7,7 +7,6 @@
- link:
~/.config/mpv/config: dotfiles/mpv
~/.config/mpv/scripts/xscreensaver.lua: mpv/xscreensaver.lua
- ~/.local/bin/brightness_monitor: bin/brightness_monitor
~/.local/bin/random_wallpaper: bin/random_wallpaper
~/.local/bin/randr_output_toggle: bin/randr_output_toggle
~/.local/bin/ssh_sk_add: bin/ssh_sk_add
@@ -19,3 +18,5 @@
~/.xscreensaver: dotfiles/xscreensaver
~/.Xresources: dotfiles/Xresources
~/.Xsession: dotfiles/Xsession
+
+- clean: [~/.local/bin/brightness_monitor]
diff --git a/dotfiles/Xsession b/dotfiles/Xsession
index 7ad3423..6ac29a2 100644
--- a/dotfiles/Xsession
+++ b/dotfiles/Xsession
@@ -22,11 +22,6 @@ run_if_exists parcellite
udev_match --subsystem=hidraw --match=ACTION=remove --match=ID_FIDO_TOKEN=1 ssh_sk_clean &
udev_match --subsystem=hidraw --match=ACTION=add --match=ID_FIDO_TOKEN=1 ssh_sk_add &
-# show notifications on brightness changes
-for d in /sys/class/backlight/*; do
- brightness_monitor "$d" &
-done
-
# source the machine-local configuration
[ -r "$HOME/.config/Xsession_local" ] && . "$HOME/.config/Xsession_local"