From 267e26ee51d0144864917249bbcce8e8ec97ec36 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ferit=20Yi=C4=9Fit=20BALABAN?= Date: Sun, 12 Jun 2022 17:48:31 +0300 Subject: [PATCH] Pause media using playerctl --- modeset2.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/modeset2.py b/modeset2.py index 68ddbb9..4d6429a 100755 --- a/modeset2.py +++ b/modeset2.py @@ -68,7 +68,7 @@ async def open_subprocess(cmd: str): async def change_wallpaper(mode: int, cringe = False): if not os.path.exists(PATH_RESC_WALLPS): - get_wallpapers(): + get_wallpapers() region = f"{mode}{1 if cringe else 0}" with open(PATH_RESC_WALLPS, 'r') as f: file = f.read() @@ -78,6 +78,11 @@ async def change_wallpaper(mode: int, cringe = False): await open_subprocess(command) +def pause_media(): + if run(["playerctl", "status"], text = True, capture_output = True).stdout == "Playing": + run(["playerctl", "pause"], text = True, capture_output = True) + + def get_wallpapers(): l0 = os.listdir(PATH_RESC_LIGHTW) d0 = os.listdir(PATH_RESC_DARKW) @@ -181,6 +186,7 @@ def main(): asyncio.run(set_volume(0, save_state = True)) asyncio.run(set_brightness(0, 0, save_state = True)) asyncio.run(set_brightness(1, 0, save_state = True)) + pause_media() elif sys.argv[0] == "--unlock": log("modeset2 started with \"--unlock\"") print("Unlock")