summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xpower116
-rwxr-xr-xweb_search58
2 files changed, 174 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
diff --git a/web_search b/web_search
new file mode 100755
index 0000000..60a1f2a
--- /dev/null
+++ b/web_search
@@ -0,0 +1,58 @@
+#!/bin/sh
+
+BROWSER="firefox"
+QUERY=$(tac ~/.config/sarc/search.txt | sort -u | dmenu -l 20 -p "Search or enter URL: ")
+SEARCH=$(echo $QUERY | sed 's/ /+/g; s/-e//')
+
+open_search() {
+ URL="duckduckgo.com/?q=$SEARCH"
+ CMD="$BROWSER $URL"
+
+ $CMD
+}
+
+open_url() {
+ CMD="$BROWSER $SEARCH"
+
+ $CMD
+}
+
+save_query() {
+ query=$(echo $SEARCH | sed 's/-e//; s/+/ /g')
+ echo $query >> ~/.config/sarc/search.txt
+}
+
+case $SEARCH in
+ *.com)
+ save_query
+ open_url
+ ;;
+ *.net)
+ save_query
+ open_url
+ ;;
+ *.org)
+ save_query
+ open_url
+ ;;
+ *.xyz)
+ save_query
+ open_url
+ ;;
+ *.me)
+ save_query
+ open_url
+ ;;
+ *.cooking)
+ save_query
+ open_url
+ ;;
+ "")
+ exit
+ ;;
+ *)
+ save_query
+ open_search
+ ;;
+esac
+