From a234dd74634a08245809086d52d051a46e412737 Mon Sep 17 00:00:00 2001 From: Derek Stevens Date: Wed, 5 Aug 2020 00:57:45 -0400 Subject: [PATCH] 0th commit --- README.md | 34 +++++++++++++++++++++++++++ extdisplay.sh | 52 +++++++++++++++++++++++++++++++++++++++++ nmtuiWin.sh | 11 +++++++++ t2stats.sh | 64 +++++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 161 insertions(+) create mode 100644 README.md create mode 100755 extdisplay.sh create mode 100755 nmtuiWin.sh create mode 100755 t2stats.sh diff --git a/README.md b/README.md new file mode 100644 index 0000000..ed67e4c --- /dev/null +++ b/README.md @@ -0,0 +1,34 @@ +# [[ zenUtils ]] + +### --refined UI helper scripts-- +#### Derek Stevens + +## About + +This is a simple collection of helper scripts to round out an experimental desktop environment: +* kwin +* rox +* tint2 +* urxvt +* dunst + +### extdisplay + +Wrapper script around xrandr to handle a second monitor on a laptop. + +### nmtuiWin + +Wrapper script around nmtui to aid in network configuration in the absence of nm-applet. + +### t2stats + +Status script to run in an Executor of tint2 which gives network and battery status. + +* __network__ is given as any of `offline`, `wired`, or `wifi/`. +* __battery__ is given as a progress/HP bar like so `[|||||| ]` where each pipe character (`|`) represents approximately 10% of charge. + +Battery alert notifications are handled by tint2 natively, even when the native battery applet is hidden, so that functionality is not present in the script. Network connection/disconnection notifications are planned. + +## License + +This collection is released permissively under the MIT License. You can do whatever you want with it. \ No newline at end of file diff --git a/extdisplay.sh b/extdisplay.sh new file mode 100755 index 0000000..7c7811a --- /dev/null +++ b/extdisplay.sh @@ -0,0 +1,52 @@ +#!/bin/sh + +# extdisplay: +# this is a wrapper around xrandr to handle one external monitor on a laptop +# (c) 2020 Derek Stevens +# MIT License -- do whatever you want + +helpme() +{ + echo "$0, wrapper for using xrandr to handle an external on a laptop" + echo "" + echo "USAGE: $0 solo|off|left-of|right-of|above|below [res]" + echo " solo\n activates the plugged monitor, deactivates the native display" + echo " off\n activates the native display, deactivates the plugged monitor" + echo " left-of, right-of, above, below\n activates the plugged monitor in the given" + echo " relation to the native display" + echo " res\n if included, sets the resolution of the plugged monitor" +} + +if [ -z $1 ]; then + helpme +fi + +native=xrandr | grep LVDS | awk '{print $1}' +plugged=xrandr | grep connected | grep -v $native | awk '{print $1}' + +if [ "$1" = solo ]; then + xrandr --output ${plugged} --primary + xrandr --output ${native} --off + xrandr --output ${plugged} --auto + if [ ! -z $2 ]; then + xrandr -s $2 + fi + +elif [ "$1" = off ]; then + xrandr --output ${native} --primary + xrandr --output ${plugged} --off + xrandr --output ${native} --auto + +else + case $1 in + right-of|left-of|above|below) + xrandr --output ${native} --auto --output ${plugged} --auto --$1 ${native} + if [ ! -z $2 ]; then + xrandr --output ${plugged} -s $2 + ;; + *) + helpme + ;; + esac +fi + diff --git a/nmtuiWin.sh b/nmtuiWin.sh new file mode 100755 index 0000000..4bd6949 --- /dev/null +++ b/nmtuiWin.sh @@ -0,0 +1,11 @@ +#!/bin/sh + +# nmtuiWin: +# this is a wrapper around urxvt+nmtui to provide easy access to network configuration +# colors are hardcoded into the urxvt instance to give it a grey+green colorscheme +# (c) 2020 Derek Stevens +# MIT License -- do whatever you want + +if [ $(pgrep nmtui) -gt 0 ]; then + exec urxvt -geometry 80x30 +sb --depth 24 --background black --color4 black --color7 grey20 --color1 seagreen --color0 grey50 -e nmtui & +fi diff --git a/t2stats.sh b/t2stats.sh new file mode 100755 index 0000000..22c34e7 --- /dev/null +++ b/t2stats.sh @@ -0,0 +1,64 @@ +#!/bin/sh + +# t2stats: +# this is a simple network/battery status indicator to be used with tint2 +# (c) 2020 Derek Stevens +# MIT License -- do whatever you want + +while true; do +# network + actives=$(nmcli connection show --active) + possiblywifi=$(echo "${actives}" | grep wifi) + possiblyeth=$(echo "${actives}" | grep Wired) + ORS=" " + + if [ ! -z "${possiblyeth}" ]; then + output=wired + elif [ ! -z "${possiblywifi}" ]; then + output="wifi/$(echo ${possiblywifi} | awk 'BEGIN { ORS=" " }; {for (i=1; i<=(NF-3);i++) print $i}')" + else + output=offline + fi + + echo -n "${output} " + +# battery + + powerlevel=$(cat /sys/class/power_supply/BAT*/capacity) + case $powerlevel in + 1|2|3|4|5|6|7|8|9) + meter="[| ]" + ;; + 10|11|12|13|14|15|16|17|18|19) + meter="[|| ]" + ;; + 20|21|22|23|24|25|26|27|28|29) + meter="[||| ]" + ;; + 30|31|32|33|34|35|36|37|38|39) + meter="[|||| ]" + ;; + 40|41|42|43|44|45|46|47|48|49) + meter="[||||| ]" + ;; + 50|51|52|53|54|55|56|57|58|59) + meter="[|||||| ]" + ;; + 60|61|62|63|64|65|66|67|68|69) + meter="[||||||| ]" + ;; + 70|71|72|73|74|75|76|77|78|79) + meter="[|||||||| ]" + ;; + 80|81|82|83|84|85|86|87|88|89) + meter="[||||||||| ]" + ;; + *) + meter="[||||||||||]" + ;; + esac + + echo "${meter}" + + sleep 10 +done \ No newline at end of file