From dbcd59ed663051453bdedeceecd2134d5475a7fb Mon Sep 17 00:00:00 2001 From: Solomon Laing Date: Thu, 10 Mar 2022 22:07:31 +1030 Subject: [PATCH] updated some scripts, added more --- install.sh | 3 + scripts/install.sh | 3 - scripts/screenshot | 13 +++ scripts/xmobar-status-keyboard | 32 +++++++ scripts/xmobar-status-net | 109 ++++++++++++++++++++++ scripts/xmobar-status-updates | 5 + scripts/xmobar-status-vol | 38 ++++++++ scripts/xmobar-trayer-padding-icon | 48 ++++++++++ scripts/{xmonad-keys => xmonad-keys-help} | 0 9 files changed, 248 insertions(+), 3 deletions(-) create mode 100755 install.sh delete mode 100644 scripts/install.sh create mode 100755 scripts/screenshot create mode 100755 scripts/xmobar-status-keyboard create mode 100755 scripts/xmobar-status-net create mode 100755 scripts/xmobar-status-updates create mode 100755 scripts/xmobar-status-vol create mode 100755 scripts/xmobar-trayer-padding-icon rename scripts/{xmonad-keys => xmonad-keys-help} (100%) diff --git a/install.sh b/install.sh new file mode 100755 index 0000000..44feb69 --- /dev/null +++ b/install.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +sudo cp scripts/* /usr/local/bin diff --git a/scripts/install.sh b/scripts/install.sh deleted file mode 100644 index 1dac9da..0000000 --- a/scripts/install.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/bash - -sudo cp scripts/* /usr/local/bin \ No newline at end of file diff --git a/scripts/screenshot b/scripts/screenshot new file mode 100755 index 0000000..7f2a66b --- /dev/null +++ b/scripts/screenshot @@ -0,0 +1,13 @@ +#!/bin/sh + +SCRIPTNAME=$(basename $0) +FILENAME="$HOME/$SCRIPTNAME-$(date +'%Y-%m-%d-%H-%M-%S').png" + +case ${1:-} in + select*|region|area) SEL="-s" ;; + *) SEL="" ;; +esac + +maim --format=png $SEL "$FILENAME" +echo -n $FILENAME | xclip -selection clipbard +notify-send "Screenshot" "$(echo -e "Screen shot saved\n$FILENAME")" diff --git a/scripts/xmobar-status-keyboard b/scripts/xmobar-status-keyboard new file mode 100755 index 0000000..835025f --- /dev/null +++ b/scripts/xmobar-status-keyboard @@ -0,0 +1,32 @@ +#!/bin/sh + +stdlayout=us # standard layout takes "default" color +stdname=en-us # arbitrary, descriptive only + +base03=#002b36 +base02=#073642 +base01=#586e75 +base00=#657b83 +base0=#839496 +base1=#93a1a1 +base2=#eee8d5 +base3=#fdf6e3 +yellow=#b58900 +orange=#cb4b16 +red=#dc322f +magenta=#d33682 +violet=#6c71c4 +blue=#268bd2 +cyan=#2aa198 +green=#859900 + +layout="$(xkb-switch)" + +case $layout in + ${stdlayout}) color=$green; icon=" "; name=$stdname ;; # f11c fa-keyboard-o + *) color=$magenta; icon=" "; name="dvorak" ;; # f11c fa-keyboard-o +esac + +echo "$icon ${name}" + +# vim: ft=sh:expandtab:ts=4:shiftwidth=4 diff --git a/scripts/xmobar-status-net b/scripts/xmobar-status-net new file mode 100755 index 0000000..98e7b44 --- /dev/null +++ b/scripts/xmobar-status-net @@ -0,0 +1,109 @@ +#!/bin/sh + +dev_wifi=wlp3s0 +dev_eth=enp0s25 +dev_vpn=proton0 + +base03=#002b36 +base02=#073642 +base01=#586e75 +base00=#657b83 +base0=#839496 +base1=#93a1a1 +base2=#eee8d5 +base3=#fdf6e3 +yellow=#b58900 +orange=#cb4b16 +red=#dc322f +magenta=#d33682 +violet=#6c71c4 +blue=#268bd2 +cyan=#2aa198 +green=#859900 + +# connectivity status +# states are: +# none (no connectivity) +# portal (behind captive portal) +# limited (connected to network but no internet access) +# full (full internet connectivity) +# unknown + +std_color=$magenta +wifi_icon="" + +connectivity="$(nmcli networking connectivity)" + +case $connectivity in + none) color=$red; icon=" " ;; # f056 fa-minus-circle + portal) color=$yellow; icon=" " ;; # f05c fa-times-circle-o + limited) color=$yellow; icon=" " ;; # f01b fa-arrow-circle-o-up + full) color=$std_color; icon=" " ;; # f0aa fa-arrow-circle-up + *) color=$red; icon=" " ;; # f29c fa-question-circle-o +esac + +eth="$(ip -o address | grep -i "$dev_eth *inet ")" +if [ -n "$eth" ] +then + #eth="${eth##*inet }" + speed="$(cat /sys/class/net/$dev_eth/speed)" + case $speed in + 10) speed="10Base-T" ;; + 100) speed="100Base-T" ;; + 1000) speed="Gigabit" ;; + *) speed="UNKNOWN $speed" ;; + esac + #eth_status="  $speed ${eth%%/*}" + eth_status="  $speed" +fi + +ssid="$(iw dev $dev_wifi link | grep -i SSID)" +if [ -n "$ssid" ] +then + signal="$(iw dev wlp4s0 station dump | egrep '[^ ]signal avg')" + signal="${signal#*-}" + signal="${signal%% *}" + signal="$((2*(100-signal)))" + +# if ((signal < 20)) +# then +# sigicon="⠀" +# elif ((signal < 40)) +# then +# sigicon="⣀" +# elif ((signal < 60)) +# then +# sigicon="⣤" +# elif ((signal < 80)) +# then +# sigicon="⣶" +# else +# sigicon="⣿" +# fi + signal=$((signal/5*5)) # get rid of some jitter + ((signal > 100)) && signal=100 + # ▁ ▂ ▃ ▄ ▅ ▆ ▇ █ + wifi_status=" $wifi_icon ${signal}% ${ssid##*SSID: }" +# if [ -n "$eth" ] +# then +# wifi_ip="$(ip -o address | grep -i "$dev_wifi *inet ")" +# wifi_ip=" ${wifi_ip##*inet }" +# wifi_status="$wifi_status${wifi_ip%%/*}" +# fi +fi + +vpn="$(ip -o address | grep -i "$dev_vpn *inet ")" +if [ -n "$vpn" ] +then + #vpn="${vpn##*inet }" + #vpn_status=" ${vpn%%/*}" + vpn_status=" " + color=$green +else + vpn_status=" " +fi + +echo "${vpn_status}$icon${connectivity##*full}$wifi_status$eth_status" + + +# vim: ft=sh:expandtab:ts=4:shiftwidth=4 diff --git a/scripts/xmobar-status-updates b/scripts/xmobar-status-updates new file mode 100755 index 0000000..7835cbb --- /dev/null +++ b/scripts/xmobar-status-updates @@ -0,0 +1,5 @@ +#!/bin/sh + +count=$(yay -Qu | wc -l) + +printf "\ufbae %s" $count diff --git a/scripts/xmobar-status-vol b/scripts/xmobar-status-vol new file mode 100755 index 0000000..9f74c59 --- /dev/null +++ b/scripts/xmobar-status-vol @@ -0,0 +1,38 @@ +#!/bin/sh + +base03=#002b36 +base02=#073642 +base01=#586e75 +base00=#657b83 +base0=#839496 +base1=#93a1a1 +base2=#eee8d5 +base3=#fdf6e3 +yellow=#b58900 +orange=#cb4b16 +red=#dc322f +magenta=#d33682 +violet=#6c71c4 +blue=#268bd2 +cyan=#2aa198 +green=#859900 + +color=$cyan +volume="$(amixer sget Master | grep 'Front Left')" +if [ "${volume}" = "${volume%\[off\]*}" ] +then + volume="${volume#*\[}" + status="${volume%%\%\]*}" + case $((status/50)) in + 0) icon="" ;; # fa-volume-down f027 + 1) icon="" ;; # fa-volume-up f028 + *) icon=""; color=$orange ;; # fa-volume-up f028 + esac +else + status=MUTE + color=$red + icon="" # fa-volume-off f026 +fi +echo "$icon $status" + + diff --git a/scripts/xmobar-trayer-padding-icon b/scripts/xmobar-trayer-padding-icon new file mode 100755 index 0000000..adee04a --- /dev/null +++ b/scripts/xmobar-trayer-padding-icon @@ -0,0 +1,48 @@ +#!/bin/sh +# Copied from https://github.com/jaor/xmobar/issues/239#issuecomment-233206552 +# Detects the width of running trayer-srg window (xprop name 'panel') +# and creates an XPM icon of that width, 1px height, and transparent. +# Outputs an -tag for use in xmobar to display the generated +# XPM icon. +# +# Run script from xmobar: +# `Run Com "/where/ever/trayer-padding-icon.sh" [] "trayerpad" 10` +# and use `%trayerpad%` in your template. + + +# Function to create a transparent Wx1 px XPM icon +create_xpm_icon () { + timestamp=$(date) + pixels=$(for i in `seq $1`; do echo -n "."; done) + + cat << EOF > "$2" +/* XPM * +static char * trayer_pad_xpm[] = { +/* This XPM icon is used for padding in xmobar to */ +/* leave room for trayer-srg. It is dynamically */ +/* updated by by trayer-padding-icon.sh which is run */ +/* by xmobar. */ +/* Created: ${timestamp} */ +/* */ +"$1 1 1 1", +/* Colors (none: transparent) */ +". c none", +/* Pixels */ +"$pixels" +}; +EOF +} + +# Width of the trayer window +width=$(xprop -name panel | grep 'program specified minimum size' | cut -d ' ' -f 5) + +# Icon file name +iconfile="/tmp/trayer-padding-${width}px.xpm" + +# If the desired icon does not exist create it +if [ ! -f $iconfile ]; then + create_xpm_icon $width $iconfile +fi + +# Output the icon tag for xmobar +echo "" diff --git a/scripts/xmonad-keys b/scripts/xmonad-keys-help similarity index 100% rename from scripts/xmonad-keys rename to scripts/xmonad-keys-help