#!/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 } kill_program() { target=$(ps ax | awk '{print $5}' | cut -d "[" -f1 | sed 's/COMMAND//g' | grep . | dmenu -p "Enter program to kill: ") sudo killall $target } 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\nkill\nstatus\nreboot\nshutdown\n" | dmenu -i -p 'Power: ')" in 'tearfree') tearing;; 'redshift') redshift;; 'Jellyfin') jellyfin;; 'compositor') compositor;; 'monero') monero;; 'VPN') vpn;; 'kill') kill_program;; 'status') status;; 'reboot') sudo reboot;; 'shutdown') sudo shutdown now;; *) exit 1;; esac