From 7fb3a5ac98a5ccff79af8d65410e18992c961cb5 Mon Sep 17 00:00:00 2001 From: Randall Winkhart Date: Sun, 26 Jun 2022 01:55:13 -0400 Subject: [PATCH] Added xcaffeine.py (self-written script) for keeping the screen awake when certain applications are open --- chrootInstall.sh | 2 +- programs/xcaffeine.desktop | 7 +++++++ programs/xcaffeine/xcaffeine.py | 32 ++++++++++++++++++++++++++++++++ 3 files changed, 40 insertions(+), 1 deletion(-) create mode 100755 programs/xcaffeine.desktop create mode 100755 programs/xcaffeine/xcaffeine.py diff --git a/chrootInstall.sh b/chrootInstall.sh index ab2bc0c..e79d1e3 100755 --- a/chrootInstall.sh +++ b/chrootInstall.sh @@ -103,7 +103,7 @@ chmod -R 700 /home # installing desktop environment and addons + utilities if [ "$formfactor" -lt 4 ]; then - pacman -S pipewire pipewire-pulse pipewire-jack pipewire-alsa plasma-desktop lightdm-openrc lightdm-gtk-greeter kscreen kdeplasma-addons spectacle gwenview plasma-nm plasma-pa breeze-gtk kde-gtk-config kio-extras khotkeys kwalletmanager pcmanfm-qt yakuake ark kate micro bluedevil bluez --needed --noconfirm + pacman -S pipewire pipewire-pulse pipewire-jack pipewire-alsa libpulse plasma-desktop lightdm-openrc lightdm-gtk-greeter kscreen kdeplasma-addons spectacle gwenview plasma-nm plasma-pa breeze-gtk kde-gtk-config kio-extras khotkeys kwalletmanager pcmanfm-qt yakuake ark kate micro bluedevil bluez --needed --noconfirm rc-update add lightdm ln -s /usr/bin/micro /usr/bin/nano fi diff --git a/programs/xcaffeine.desktop b/programs/xcaffeine.desktop new file mode 100755 index 0000000..d69b320 --- /dev/null +++ b/programs/xcaffeine.desktop @@ -0,0 +1,7 @@ +[Desktop Entry] + Exec=/usr/bin/xcaffeine.py + Icon= + Name=xcaffeine + Path= + Terminal=False + Type=Application diff --git a/programs/xcaffeine/xcaffeine.py b/programs/xcaffeine/xcaffeine.py new file mode 100755 index 0000000..f1cb38f --- /dev/null +++ b/programs/xcaffeine/xcaffeine.py @@ -0,0 +1,32 @@ +#!/bin/python3 + +# external modules + +from os import setuid, system +from pwd import getpwnam +from subprocess import Popen, PIPE, STDOUT +from time import sleep + +# depends on X11, libpulse (compatible w/Pipewire&PulseAudio) + +# START USER CHANGEABLE VARIABLES +# list of pactl search terms +pactl_search = ['jellyfinmediaplayer', 'rpcs3'] +# frequency to check for activity (in seconds) +timeout = 290 +# FINISH USER CHANGEABLE VARIABLES + +# ensure running as correct user +setuid(1000) + +while True: + sleep(timeout) + for search_term in pactl_search: + command = f"pactl list | grep {search_term[:-1]}" + output = Popen(command, shell=True, stdin=PIPE, stdout=PIPE, stderr=STDOUT, close_fds=True) + block = output.communicate()[0].strip() # blocks the program from proceeding until stdout is given + if block.decode('utf-8').__contains__(search_term): + print(f"Whitelisted content ({search_term}) is active, keeping screen alive...") + system('xset s off -dpms') + sleep(5) + system('xset s on +dpms')