diff options
Diffstat (limited to 'config/X/xmobar/scripts')
-rw-r--r-- | config/X/xmobar/scripts/.updates.swp | bin | 0 -> 12288 bytes | |||
-rwxr-xr-x | config/X/xmobar/scripts/battery | 13 | ||||
-rwxr-xr-x | config/X/xmobar/scripts/checkupds | 2 | ||||
-rwxr-xr-x | config/X/xmobar/scripts/minwinfo | 5 | ||||
-rwxr-xr-x | config/X/xmobar/scripts/whscreen | 23 | ||||
-rwxr-xr-x | config/X/xmobar/scripts/winfo | 124 | ||||
-rw-r--r-- | config/X/xmobar/scripts/winfo_icons | 15 |
7 files changed, 182 insertions, 0 deletions
diff --git a/config/X/xmobar/scripts/.updates.swp b/config/X/xmobar/scripts/.updates.swp Binary files differnew file mode 100644 index 0000000..99422fc --- /dev/null +++ b/config/X/xmobar/scripts/.updates.swp diff --git a/config/X/xmobar/scripts/battery b/config/X/xmobar/scripts/battery new file mode 100755 index 0000000..77b0d29 --- /dev/null +++ b/config/X/xmobar/scripts/battery @@ -0,0 +1,13 @@ +#!/usr/bin/env bash +battery="$(acpi -i | awk -F ',' 'NR==1 {print $2}')" +charging="$(acpi -i | awk 'NR==1 {print $3}')" +battery=${battery:1:-1} +if [[ "${charging::-1}" == "Charging" ]] +then + icon="<fn=1></fn>" +else + index=$((battery/25)) + array=("<fn=1></fn>" "<fn=1></fn>" "<fn=1></fn>" "<fn=1></fn>" "<fn=1></fn>") + icon="${array[$index]}" +fi +echo -n " ${battery}% ${icon}" diff --git a/config/X/xmobar/scripts/checkupds b/config/X/xmobar/scripts/checkupds new file mode 100755 index 0000000..6cc6030 --- /dev/null +++ b/config/X/xmobar/scripts/checkupds @@ -0,0 +1,2 @@ +#!/usr/bin/env bash +checkupdates | wc -l diff --git a/config/X/xmobar/scripts/minwinfo b/config/X/xmobar/scripts/minwinfo new file mode 100755 index 0000000..1736a5f --- /dev/null +++ b/config/X/xmobar/scripts/minwinfo @@ -0,0 +1,5 @@ +#!/usr/bin/env bash +# +echo "name: $1" +echo "icon: $2" +echo "sentence: $3" diff --git a/config/X/xmobar/scripts/whscreen b/config/X/xmobar/scripts/whscreen new file mode 100755 index 0000000..030493b --- /dev/null +++ b/config/X/xmobar/scripts/whscreen @@ -0,0 +1,23 @@ +#!/bin/bash + +# # -- Based on mouse +# # Get mouse location, only X matters +# X=$(\ +# xdotool getmouselocation -s \ +# | head -n1 \ +# | cut -f2 -d'='\ +# ) + +# Based on active window +X=$(xdotool getwindowgeometry -s $(xdotool getwindowfocus) | grep "X" | cut -d'=' -f2) + +# For dual monitor setup +monitor_width="$(\ + xdotool getdisplaygeometry \ + | cut -d ' ' -f 1 \ +)" + +# If '-' number is negative +[[ "$((${X} - ${monitor_width}))" -lt 0 ]] \ + && echo -n '<' \ + || echo -n '>' diff --git a/config/X/xmobar/scripts/winfo b/config/X/xmobar/scripts/winfo new file mode 100755 index 0000000..033ab49 --- /dev/null +++ b/config/X/xmobar/scripts/winfo @@ -0,0 +1,124 @@ +#!/bin/bash +XMDIR="$HOME/.config/xmobar" + +terminal="$(\ + grep -m 1 "myTerminal *=" ~/.config/xmonad/xmonad.hs \ + | cut -f 2 -d '"' \ +)" + +# Gets info over active window in X server +# made to work with xmobar +# Make option to change the terminal + +# ID of focused window +GetWinID () { + xdotool getWindowfocus +} + +# Gets name of program running active window +GetWinName () { + xdotool getwindowclassname $(GetWinID) +} + +GetWinIcons () { + NAME="$(GetWinName | cut -f 1 -d " ")" + test -z "$NAME" || \ + grep -i -m 1 "${NAME}" "$XMDIR/scripts/winfo_icons" | cut -f1 -d' ' +} + +# Get current directory of active window +# for st +GetCWD (){ + # Parent PID of process running in window + PARENT_PID="$(\ + xdotool getwindowpid $(GetWinID)\ + )" + + # PID of process runnning in window + PROCESS="$(\ + pstree -p ${PARENT_PID} \ + | head -n1 \ + | sed \ + -e 's/^.*-\(.*\)$/\1/g' \ + -e 's/^ *\([^{:( ]*\).*$/\1/g' \ + )" + + echo -n "${PROCESS}" \ + | sed \ + -e "s;^zsh$;<fn=1></fn>&;g" \ + -e "s;^htop$;<fn=1></fn> &;g" \ + -e "s;^ranger$;<fn=1></fn> &;g" +} + +# Get title of window / name of process +# takes one argument, window name +GetWinTitle() { + # Max length of string + MAX_LEN=64 + xdotool GetWindowName $(GetWinID) \ + | sed \ + -e 's/ — Mozilla Firefox//g' \ + -e "s;${HOME};~;g" \ + -e "s/^\(.\{$MAX_LEN\}\).*$/\1../g" \ + -e 's/ *\.\.$/\.\./g' \ + -e "s;^${terminal^}$;$(GetCWD);g" +} + +# Help function +Help () { + echo "-- This is winfo --" + echo "Gets information over focused window" + echo + echo "Usage: getFWinfo [OPTION]" + echo " -h display this help and exit" + echo " -n for name" + echo " -i for icons" + echo " -t for titles" +} + +############################################## +#################### MAIN #################### +############################################## + +# Handles options +if [ $# -eq 0 ] +then + Help + exit 0 +fi + +while getopts ":hinTt" option +do + case "$option" in + + h) # Prints help message + Help + exit 0 + ;; + + T) # Get terminal specified by xmonad + echo ${terminal} + exit 0 + ;; + + i) # Get window icons, uses GetWinName + GetWinIcons + exit 0 + ;; + + n) # Get window name "WM_CLASS" + GetWinName + # Capitalize + exit 0 + ;; + + t) # Get window title, like name of webpage/working dir + GetWinTitle + exit 0 + ;; + + esac +done + echo "Invalid option." + Help + exit 1 diff --git a/config/X/xmobar/scripts/winfo_icons b/config/X/xmobar/scripts/winfo_icons new file mode 100644 index 0000000..dbdc3ae --- /dev/null +++ b/config/X/xmobar/scripts/winfo_icons @@ -0,0 +1,15 @@ +<fn=1></fn> alacritty kitty +<fn=1></fn> firefox +<fn=1></fn> minecraft multimc +<fn=1></fn> virt-manager virtualbox rustdesk +<fn=1></fn> mpv +<fn=1>ﭮ</fn> discord +<fn=1></fn> jetbrains-clion +<fn=1></fn> pinentry-gtk-2 +<fn=1></fn> code-oss +<fn=1>響</fn> mumble +<fn=1></fn> soffice libreoffice-writer +<fn=1></fn> steam +<fn=1></fn> packettracer +<fn=1></fn> ktouch +<fn=1></fn> signal |