Created
January 6, 2022 15:46
-
-
Save Monsterovich/271f88fe46d80564e18f2ed040c53cf0 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
from gi.repository import GLib | |
from gi.repository import Gio | |
import os | |
import time | |
def onPrepareForSleep(conn, sender, obj, interface, signal, parameters, data): | |
if not parameters[0]: | |
print('Triggered') | |
time.sleep(5) | |
os.system('pactl set-default-sink alsa_output.pci-0000_07_00.4.analog-stereo') | |
system_bus = Gio.bus_get_sync(Gio.BusType.SYSTEM, None) | |
system_bus.signal_subscribe('org.freedesktop.login1', | |
'org.freedesktop.login1.Manager', | |
'PrepareForSleep', | |
'/org/freedesktop/login1', | |
None, | |
Gio.DBusSignalFlags.NONE, | |
onPrepareForSleep, | |
None) | |
print('Starting main loop') | |
GLib.MainLoop().run() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment