dotfiles

configuration files for shell, text editor, graphical environment, etc.
git clone git://src.adamsgaard.dk/dotfiles
Log | Files | Refs | README | LICENSE Back to index

commit fa7d5d843bbb723261b2ae48fb4fae42f983864e
parent c182b42700ca10491a15bb10d39b66210d584c20
Author: Anders Damsgaard <anders@adamsgaard.dk>
Date:   Sat, 15 Dec 2018 08:49:18 +0100

Add i3 scripts from lukesmithxyz

Diffstat:
Alinks/.config/i3/i3scripts/i3battery | 34++++++++++++++++++++++++++++++++++
Alinks/.config/i3/i3scripts/i3cpu | 12++++++++++++
Alinks/.config/i3/i3scripts/i3date | 12++++++++++++
Alinks/.config/i3/i3scripts/i3disk | 20++++++++++++++++++++
Alinks/.config/i3/i3scripts/i3help | 9+++++++++
Alinks/.config/i3/i3scripts/i3internet | 18++++++++++++++++++
Alinks/.config/i3/i3scripts/i3mail | 18++++++++++++++++++
Alinks/.config/i3/i3scripts/i3mem | 11+++++++++++
Alinks/.config/i3/i3scripts/i3mpd | 19+++++++++++++++++++
Alinks/.config/i3/i3scripts/i3mpdupdate | 9+++++++++
Alinks/.config/i3/i3scripts/i3news | 18++++++++++++++++++
Alinks/.config/i3/i3scripts/i3pacman | 16++++++++++++++++
Alinks/.config/i3/i3scripts/i3torrent | 6++++++
Alinks/.config/i3/i3scripts/i3volume | 26++++++++++++++++++++++++++
Alinks/.config/i3/i3scripts/i3weather | 22++++++++++++++++++++++
Alinks/.config/i3/i3scripts/popupgrade | 10++++++++++
16 files changed, 260 insertions(+), 0 deletions(-)

diff --git a/links/.config/i3/i3scripts/i3battery b/links/.config/i3/i3scripts/i3battery @@ -0,0 +1,34 @@ +#!/bin/sh +# Give a battery name (e.g. BAT0) as an argument. + +case $BLOCK_BUTTON in + 3) pgrep -x dunst >/dev/null && notify-send "<b>🔋 Battery module:</b> +🔋: discharging +♻: stagnant charge +🔌: charging +⚡: charged +❗: battery very low! +- Text color reflects charge left" ;; +esac + +capacity=$(cat /sys/class/power_supply/"$1"/capacity) || exit +status=$(cat /sys/class/power_supply/"$1"/status) + +if [ "$capacity" -ge 80 ]; then + color="#b8bb26" +elif [ "$capacity" -ge 60 ]; then + color="#ebdbb2" +elif [ "$capacity" -ge 40 ]; then + color="#fabd2f" +elif [ "$capacity" -ge 20 ]; then + color="#fe8019" +else + color="#fb4934" + warn="❗" +fi + +[ -z $warn ] && warn=" " + +[ "$status" = "Charging" ] && color="#FFF" + +printf "<span color='%s'>%s%s%s</span>" "$color" "$(echo "$status" | sed -e "s/,//g;s/Discharging/🔋/;s/Charging/🔌/;s/Unknown/♻️/;s/Full/⚡/;s/ 0*/ /g;s/ :/ /g")" "$warn" "$(echo "$capacity" | sed -e 's/$/%/')" diff --git a/links/.config/i3/i3scripts/i3cpu b/links/.config/i3/i3scripts/i3cpu @@ -0,0 +1,12 @@ +#!/bin/sh + +case $BLOCK_BUTTON in + 1) notify-send "<b>🖥 CPU hogs</b>: +$(ps axch -o cmd:15,%cpu --sort=-%cpu | head)" ;; + 3) notify-send "<b>🖥 CPU module:</b> +- Shows CPU temperature. +- Click to show intensive processes. +- % is of single core." ;; +esac + +sensors | awk '/^temp1/ {print $2}' diff --git a/links/.config/i3/i3scripts/i3date b/links/.config/i3/i3scripts/i3date @@ -0,0 +1,12 @@ +#!/bin/sh + +date '+%Y %b %d (%a) %I:%M%p' + +case $BLOCK_BUTTON in + 1) pgrep -x dunst >/dev/null && notify-send "$(cal --color=always | sed "s/..7m/<b><span color=\"red\">/;s/..27m/<\/span><\/b>/")" ;; + 2) "$TERMINAL" -e calcurse ;; + 3) pgrep -x dunst >/dev/null && notify-send "<b>📅 Time/date module:</b> +- Left click to show month via \`cal\` +- Middle click opens calcurse if installed" ;; +esac + diff --git a/links/.config/i3/i3scripts/i3disk b/links/.config/i3/i3scripts/i3disk @@ -0,0 +1,20 @@ +#!/bin/sh + +# Status bar module for disk space +# $1 should be drive mountpoint +# $2 is optional icon, otherwise mountpoint will displayed + +[ -z "$1" ] && exit + +icon="$2" +[ -z "$2" ] && icon="$1" + +case $BLOCK_BUTTON in + 1) pgrep -x dunst >/dev/null && notify-send "<b>💽 Disk space:</b> +$(df -h --output=target,used,size)" ;; + 3) pgrep -x dunst >/dev/null && notify-send "<b>💽 Hard drive space remaining:</b> +- Shows used hard drive space. +- Click to show all disk info." ;; +esac + +printf "%s: %s" "$icon" "$(df -h "$1" | awk ' /[0-9]/ {print $3 "/" $2}')" diff --git a/links/.config/i3/i3scripts/i3help b/links/.config/i3/i3scripts/i3help @@ -0,0 +1,9 @@ +#!/bin/sh + +case $BLOCK_BUTTON in + 1) groff -mom ~/.readme.mom -Tpdf | zathura - ;; + 3) pgrep -x dunst >/dev/null && notify-send "<b>❓ Help module:</b> +- Left click to open LARBS guide.";; +esac + +echo "❓" diff --git a/links/.config/i3/i3scripts/i3internet b/links/.config/i3/i3scripts/i3internet @@ -0,0 +1,18 @@ +#!/bin/sh + +case $BLOCK_BUTTON in + 1) $TERMINAL -e nmtui ;; + 3) pgrep -x dunst >/dev/null && notify-send "<b>🌐 Internet module:</b> +- Click for \`nmtui\` for wifi access +📡: no wifi connection +📶: wifi connection with quality +❎: no ethernet +🌐: ethernet working +" ;; +esac + +[ "$(cat /sys/class/net/w*/operstate)" = 'down' ] && wifiicon="📡" + +[ ! -n "${wifiicon+var}" ] && wifiicon=$(grep "^\s*w" /proc/net/wireless | awk '{ print "📶", int($3 * 100 / 70) "%" }') + +printf "%s %s" "$wifiicon" "$(cat /sys/class/net/e*/operstate | sed "s/down/❎/;s/up/🌐/")" diff --git a/links/.config/i3/i3scripts/i3mail b/links/.config/i3/i3scripts/i3mail @@ -0,0 +1,18 @@ +#!/bin/sh + +# i3blocks mail module. +# Displays number of unread mail and an loading icon if updating. +# When clicked, brings up `neomutt`. + +case $BLOCK_BUTTON in + 1) "$TERMINAL" -e neomutt ;; + 2) setsid $HOME/.config/mutt/etc/mailsync.sh >/dev/null & ;; + 3) pgrep -x dunst >/dev/null && notify-send "<b>📬 Mail module:</b> +- Shows unread mail +- Shows 🔃 if syncing mail +- Left click opens neomutt +- Middle click syncs mail" ;; +esac + +echo "$(du -a ~/.mail/*/INBOX/new/* 2>/dev/null | sed -n '$=')$(cat ~/.config/mutt/.dl 2>/dev/null)" + diff --git a/links/.config/i3/i3scripts/i3mem b/links/.config/i3/i3scripts/i3mem @@ -0,0 +1,11 @@ +#!/bin/sh + +case $BLOCK_BUTTON in + 1) notify-send "<b>🧠 Memory hogs:</b> +$(ps axch -o cmd:15,%mem --sort=-%mem | head)" ;; + 3) notify-send "<b>🧠 Memory module:</b> +- Shows Memory Used/Total. +- Click to show memory hogs." ;; +esac + +free -h | awk '/^Mem:/ {print $3 "/" $2}' diff --git a/links/.config/i3/i3scripts/i3mpd b/links/.config/i3/i3scripts/i3mpd @@ -0,0 +1,19 @@ +#!/bin/sh + +filter() { + sed "/^volume:/d" | tac | sed -e "s/\\&/&amp;/g;s/\\[paused\\].*/<span color=\"gray\" font_style=\"italic\">/g;s/\\[playing\\].*/<span>/g" | tr -d '\n' | sed -e "s/$/<\\/span>/g" + } + +case $BLOCK_BUTTON in + 1) mpc status | filter && setsid "$TERMINAL" -e ncmpcpp & ;; # right click, pause/unpause + 2) mpc toggle | filter ;; # right click, pause/unpause + 3) mpc status | filter && pgrep -x dunst >/dev/null && notify-send "<b>🎵 Music module:</b> +- Shows mpd song playing. +- Italic when paused. +- Left click opens ncmpcpp. +- Middle click pauses. +- Scroll changes track.";; # right click, pause/unpause + 4) mpc prev | filter ;; # scroll up, previous + 5) mpc next | filter ;; # scroll down, next + *) mpc status | filter ;; +esac diff --git a/links/.config/i3/i3scripts/i3mpdupdate b/links/.config/i3/i3scripts/i3mpdupdate @@ -0,0 +1,9 @@ +#!/bin/sh + +[ "$(pgrep -x i3mpdupdate | wc -l)" -gt 2 ] && exit + +while : ; do + pgrep -x mpd || exit + mpc idle > /dev/null + pkill -RTMIN+11 i3blocks ; +done diff --git a/links/.config/i3/i3scripts/i3news b/links/.config/i3/i3scripts/i3news @@ -0,0 +1,18 @@ +#!/bin/sh + +# i3blocks newsboat module. +# Displays number of unread news items and an loading icon if updating. +# When clicked, brings up `newsboat`. + +case $BLOCK_BUTTON in + 1) setsid "$TERMINAL" -e newsboat ;; + 2) setsid newsup >/dev/null ;; + 3) pgrep -x dunst >/dev/null && notify-send "<b>📰 News module:</b> +- Shows unread news items +- Shows 🔃 if updating with \`newsup\` +- Left click opens newsboat +- Middle click syncs RSS feeds +<b>Note:</b> Only one instance of newsboat (including updates) may be running at a time." ;; +esac + +echo "$(newsboat -x print-unread | awk '{ print $1}' | sed s/^0$//g)$(cat ~/.config/newsboat/.update 2>/dev/null)" diff --git a/links/.config/i3/i3scripts/i3pacman b/links/.config/i3/i3scripts/i3pacman @@ -0,0 +1,16 @@ +#!/bin/sh + +# i3blocks module for pacman upgrades. +# Displays number of upgradeable packages. +# For this to work, have a `pacman -Sy` command run in the background as a +# cronjob every so often as root. This script will then read those packages. +# When clicked, it will run an upgrade via pacman. + +case $BLOCK_BUTTON in + 1) $TERMINAL -e popupgrade ;; + 3) pgrep -x dunst >/dev/null && notify-send "<b>Upgrade module:</b> +📦: number of upgradable packages" ;; +esac + + +pacman -Qu | wc -l | sed -e "s/^0$//g" diff --git a/links/.config/i3/i3scripts/i3torrent b/links/.config/i3/i3scripts/i3torrent @@ -0,0 +1,6 @@ +#!/bin/sh +case $BLOCK_BUTTON in + 1) $TERMINAL -e transmission-remote-cli +esac + +transmission-remote -l | grep % | sed -e "s/.*100%.*/Z/g;s/.*Idle.*/A/g;s/.*%.*/M/g" | sort -h | uniq -c | sed -e "s/Z/🌱/g;s/M/⬇️/g;s/A/⌛️/g" | awk '{print $2, $1}' | tr '\n' ' ' | sed -e "s/ $//g" diff --git a/links/.config/i3/i3scripts/i3volume b/links/.config/i3/i3scripts/i3volume @@ -0,0 +1,26 @@ +#!/bin/sh + +case $BLOCK_BUTTON in + 1) setsid "$TERMINAL" -e pulsemixer & ;; + 2) pulsemixer --toggle-mute ;; + 4) pulsemixer --change-volume +5 ;; + 5) pulsemixer --change-volume -5 ;; + 3) pgrep -x dunst >/dev/null && notify-send "<b>📢 Volume module:</b> +- Shows volume 🔊, 🔇 if muted. +- Middle click to mute. +- Scroll to change." +esac + +[ "$(pulsemixer --get-mute)" = "1" ] && printf "🔇\\n" && exit + +vol=$(pulsemixer --get-volume | awk '{print $1}') + +if [ "$vol" -gt "70" ]; then + icon="🔊" +elif [ "$vol" -lt "30" ]; then + icon="🔈" +else + icon="🔉" +fi + +printf "%s %s%%\\n" "$icon" "$vol" diff --git a/links/.config/i3/i3scripts/i3weather b/links/.config/i3/i3scripts/i3weather @@ -0,0 +1,22 @@ +#!/bin/sh +### This is only if your location isn't automatically detected, otherwise you can leave it blank. +location="" + +case $BLOCK_BUTTON in + 1) $TERMINAL -e less -S ~/.weatherreport ;; + 3) pgrep -x dunst >/dev/null && notify-send "<b>🌈 Weather module:</b> +- Click for wttr.in forecast. +☔: Chance of rain/snow +❄: Daily low +🌞: Daily high" ;; +esac + +[ "$location" != "" ] && location="$location+" + +ping -q -w 1 -c 1 "$(ip r | grep default | tail -1 | cut -d ' ' -f 3)" >/dev/null || exit + +curl -s wttr.in/$location > ~/.weatherreport + +printf "%s" "$(sed '16q;d' ~/.weatherreport | grep -wo "[0-9]*%" | sort -n | sed -e '$!d' | sed -e "s/^/☔ /g" | tr -d '\n')" + +sed '13q;d' ~/.weatherreport | grep -o "m\\(-\\)*[0-9]\\+" | sort -n -t 'm' -k 2n | sed -e 1b -e '$!d' | tr '\n|m' ' ' | awk '{print " ❄️",$1 "°","🌞",$2 "°"}' diff --git a/links/.config/i3/i3scripts/popupgrade b/links/.config/i3/i3scripts/popupgrade @@ -0,0 +1,10 @@ +#!/bin/sh + +printf "Beginning upgrade.\\n" + +yay -Syu +pacman -Qu | wc -l > ~/.pacupgrnum +pkill -RTMIN+8 i3blocks + +printf "\\nUpgrade complete.\\nPress <Enter> to exit window.\\n\\n" +read -r