Revert "xss-dimmer: play a sound to notice dimmer when not looking at the screen"

This reverts commit 398ef9263b. pygame
intercepts SIGTERM. Maybe we could use Gstreamer instead. No time for
that, let just remove this feature for now.
This commit is contained in:
Vincent Bernat 2022-05-11 20:55:42 +02:00
parent d3c6c5c8cc
commit e52f0e4bc3
2 changed files with 2 additions and 24 deletions

View file

@ -17,17 +17,10 @@ import argparse
import threading import threading
import time import time
import math import math
import os
from Xlib import display, X from Xlib import display, X
from Xlib.error import BadWindow from Xlib.error import BadWindow
from Xlib.protocol.event import MapNotify from Xlib.protocol.event import MapNotify
try:
os.environ["PYGAME_HIDE_SUPPORT_PROMPT"] = "hide"
import pygame
except ImportError:
pygame = None
def on_xevent(source, condition, xdisplay, locker): def on_xevent(source, condition, xdisplay, locker):
while xdisplay.pending_events(): while xdisplay.pending_events():
@ -96,17 +89,7 @@ def on_refresh(window, options, start):
elapsed = time.monotonic() - start elapsed = time.monotonic() - start
if elapsed < options.delay: if elapsed < options.delay:
next_step = min(options.step, options.delay - elapsed) next_step = min(options.step, options.delay - elapsed)
GLib.timeout_add(next_step * 1000, on_refresh, window, options, start) GLib.timeout_add(options.step * 1000, on_refresh, window, options, start)
def on_sound_ticker(options, sound, start):
elapsed = time.monotonic() - start
if elapsed < options.delay:
if sound is None:
pygame.mixer.init()
sound = pygame.mixer.Sound(options.sound)
sound.play()
GLib.timeout_add(1000, on_sound_ticker, options, sound, now)
# See: https://easings.net/ # See: https://easings.net/
@ -161,7 +144,6 @@ if __name__ == "__main__":
choices=easing_functions.keys(), choices=easing_functions.keys(),
help="easing function for opacity", help="easing function for opacity",
) )
add("--sound", help="play a sound for each second elapsed while dimmer running")
options = parser.parse_args() options = parser.parse_args()
background = None background = None
@ -210,8 +192,5 @@ if __name__ == "__main__":
) )
xdisplay.pending_events() # otherwise, socket is inactive xdisplay.pending_events() # otherwise, socket is inactive
if options.sound and pygame:
GLib.timeout_add(5000, on_sound_ticker, options, None, now)
# Main loop # Main loop
Gtk.main() Gtk.main()

View file

@ -3,5 +3,4 @@ Description=Screen dimmer
[Service] [Service]
ExecStart=%h/.config/i3/bin/xss-dimmer --delay=%i \ ExecStart=%h/.config/i3/bin/xss-dimmer --delay=%i \
--background=%t/i3/current-wallpaper.png \ --background=%t/i3/current-wallpaper.png
--sound=/usr/share/sounds/freedesktop/stereo/audio-volume-change.oga