summaryrefslogtreecommitdiff
path: root/power
diff options
context:
space:
mode:
authorstkhan <personal@slickd.xyz>2023-12-10 21:26:56 -0600
committerstkhan <personal@slickd.xyz>2023-12-10 21:26:56 -0600
commitcc4412e7144b32cca0ab7384b3ef3cbc6ee8c25c (patch)
treed8168de3f256f99538d0f9539e8c2624edcad374 /power
Init
Diffstat (limited to 'power')
-rwxr-xr-xpower116
1 files changed, 116 insertions, 0 deletions
diff --git a/power b/power
new file mode 100755
index 0000000..6d39e3b
--- /dev/null
+++ b/power
@@ -0,0 +1,116 @@
+#!/bin/sh
+
+tearing() {
+ status=$(xrandr --verbose | grep TearFree | head -n 1 | xargs)
+ if [[ $status == "TearFree: on" ]]; then
+ xrandr --output HDMI-A-0 --set TearFree off
+ else
+ xrandr --output HDMI-A-0 --set TearFree on
+ fi
+}
+
+jellyfin() {
+ status=$(pidof jellyfin)
+ if [[ -z $status ]]; then
+ jellyfin
+ else
+ killall jellyfin
+ fi
+}
+
+compositor() {
+ status=$(pidof picom)
+ if [[ -z $status ]]; then
+ picom
+ else
+ killall picom
+ fi
+}
+
+redshift() {
+ status=$(pidof redshift)
+ if [[ -z $status ]]; then
+ redshift_run
+ else
+ killall redshift
+ fi
+}
+
+vpn() {
+ status=$(sudo wg | sed 1q)
+ if [[ $status = 'interface: wg0-client-cl1' ]]
+ then
+ vpnStatus=on
+ else
+ vpnStatus=off
+ fi
+ case "$(printf "on\noff" | dmenu -i -p "VPN is $vpnStatus: ")" in
+ 'on')
+ wg-quick up ~/.config/wg0-client-cl1.conf
+ notify-send "VPN is turned ON";;
+ 'off')
+ wg-quick down ~/.config/wg0-client-cl1.conf
+ notify-send "VPN is OFF";;
+ *) exit 1;;
+ esac
+}
+
+monero() {
+ status=$(pidof xmrig)
+ if [[ -z $status ]]; then
+ status=off
+ else
+ status=on
+ fi
+ case "$(printf "on\noff" | dmenu -i -p "Monero is $status: ")" in
+ 'on') /home/khan/projects/monero/xmrig/run;;
+ 'off') sudo killall xmrig;;
+ *) exit 1;;
+ esac
+}
+
+status() {
+ redstats=$(pidof redshift)
+ compstats=$(pidof picom)
+ tearing=$(xrandr --verbose | grep TearFree | head -n 1 | xargs)
+ moneropid=$(pidof xmrig)
+
+ if [[ -z $redstats ]]; then
+ redstats=off
+ else
+ redstats=on
+ fi
+
+ if [[ -z $compstats ]]; then
+ compstats=off
+ else
+ compstats=on
+ fi
+
+ if [[ -z $moneropid ]]; then
+ moneropid=off
+ else
+ moneropid=on
+ fi
+
+ if [[ $tearing == "TearFree: on" ]]; then
+ tearing=on
+ else
+ tearing=off
+ fi
+
+ notify-send Status "Redshift: $redstats\nTearFree: $tearing\nMonero: $moneropid\nCompositor: $compstats"
+}
+
+case "$(printf "compositor\ntearfree\nredshift\nJellyfin\nmonero\nVPN\nstatus\nreboot\nshutdown\n" | dmenu -i -p 'Power: ')" in
+ 'tearfree') tearing;;
+ 'redshift') redshift;;
+ 'Jellyfin') jellyfin;;
+ 'compositor') compositor;;
+ 'monero') monero;;
+ 'VPN') vpn;;
+ 'status') status;;
+ 'reboot') sudo reboot;;
+ 'shutdown') sudo shutdown now;;
+ *) exit 1;;
+esac