dotfiles

custom dotfiles
git clone git://git.pyratebeard.net/dotfiles.git
Log | Files | Refs | README

commit 4c7d89d1ca6084077e7718d65361531af00b755b
parent b3e52773c83781f7ab807410051e6371ca2e0b3e
Author: pyratebeard <root@pyratebeard.net>
Date:   Sun, 14 Apr 2019 17:21:45 +0100

new scripts

Diffstat:
Abin/bin/az | 2++
Abin/bin/blocks1 | 3+++
Abin/bin/check-battery.sh | 74++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Abin/bin/gotty | 0
Abin/bin/lock | 2++
Abin/bin/panes | 23+++++++++++++++++++++++
6 files changed, 104 insertions(+), 0 deletions(-)

diff --git a/bin/bin/az b/bin/bin/az @@ -0,0 +1,2 @@ +#!/usr/bin/env bash +/home/pyratebeard/src/warez/azure-cli/bin/python -m azure.cli "$@" diff --git a/bin/bin/blocks1 b/bin/bin/blocks1 @@ -0,0 +1,3 @@ +#!/usr/bin/env bash +pcs() { for i in {0..7}; do echo -en "\e[${1}$((30+$i))m \u2588\u2588 \e[0m"; done; } +printf "\n%s\n%s\n\n" "$(pcs)" "$(pcs '1;')" diff --git a/bin/bin/check-battery.sh b/bin/bin/check-battery.sh @@ -0,0 +1,74 @@ +#!/usr/bin/env bash + +BAT_NUM='0' +STATUS_FILE=/tmp/check-bat.tmp +BATTPERC=$(cat /sys/class/power_supply/BAT${BAT_NUM}/capacity) +BATTSTATUS=$(cat /sys/class/power_supply/BAT${BAT_NUM}/status) +LAST_STATUS='' +LAST_NOTIF_LEVEL=0 +NOTIF_LEVEL=0 + +if [ -e $STATUS_FILE ] ; then + . $STATUS_FILE +fi + +save_status() { + LAST_STATUS=$BATTSTATUS + echo "LAST_STATUS=${BATTSTATUS}" > $STATUS_FILE + echo "LAST_NOTIF_LEVEL=${NOTIF_LEVEL}" >> $STATUS_FILE +} + +notify() { + level=$1 + msg=$2 + DISPLAY=:0 /usr/bin/notify-send -t 3500 -u "$level" "POWER" "$msg" +} + +# Battery status changed +if [[ "$BATTSTATUS" != "$LAST_STATUS" ]] ; then + notify "normal" "battery is now $BATTSTATUS, Capacity: $BATTPERC" + save_status + exit +fi + +if [ "$BATTSTATUS" = Discharging ] && [ "$BATTPERC" -le 10 ]; then + NOTIF_LEVEL=10 + notify "critical" "battery is less than 10% - Connect charger, going to sleep in 10s" + sleep 10 + BATTSTATUS=$(cat /sys/class/power_supply/BAT${BAT_NUM}/status) + if [ "$BATTSTATUS" = Discharging ]; then + notify "critical" "going to suspend now" + sleep 3 + logger "Critical battery threshold, suspending" + systemctl suspend + else + notify "normal" "battery is now charging, cancelling suspend" + fi + save_status + exit +fi + +if [[ $BATTPERC -le 20 ]] ; then + NOTIF_LEVEL=20 + notify "critical" "battery $BATTSTATUS is less than 20%" + save_status +elif [[ $BATTPERC -le 30 ]] ; then + NOTIF_LEVEL=30 + if [ "$NOTIF_LEVEL" != "$LAST_NOTIF_LEVEL" ]; then + notify "normal" "battery $BATTSTATUS is at 30%" + save_status + fi +elif [[ $BATTPERC -le 50 ]] ; then + NOTIF_LEVEL=50 + if [ "$NOTIF_LEVEL" != "$LAST_NOTIF_LEVEL" ] ; then + notify "low" "battery $BATTSTATUS is at 50%" + save_status + fi +elif [[ $BATTPERC -le 60 ]] ; then + NOTIF_LEVEL=60 + if [ "$NOTIF_LEVEL" != "$LAST_NOTIF_LEVEL" ] ; then + notify "normal" "battery $BATTSTATUS is at 60%" + save_status + fi +fi + diff --git a/bin/bin/gotty b/bin/bin/gotty Binary files differ. diff --git a/bin/bin/lock b/bin/bin/lock @@ -0,0 +1,2 @@ +#pkill ssh-agent ; pkill gpg-agent +/home/pyratebeard/src/warez/i3lock-fancy-multimonitor/lock -p -n diff --git a/bin/bin/panes b/bin/bin/panes @@ -0,0 +1,23 @@ +#!/usr/bin/env bash + +# Author: GekkoP +# Source: http://linuxbbq.org/bbs/viewtopic.php?f=4&t=1656#p33189 + +f=3 b=4 +for j in f b; do + for i in {0..7}; do + printf -v $j$i %b "\e[${!j}${i}m" + done +done +d=$'\e[1m' +t=$'\e[0m' +v=$'\e[7m' + + +cat << EOF + + $f1███$d▄$t $f2███$d▄$t $f3███$d▄$t $f4███$d▄$t $f5███$d▄$t $f6███$d▄$t $f7███$d▄$t + $f1███$d█$t $f2███$d█$t $f3███$d█$t $f4███$d█$t $f5███$d█$t $f6███$d█$t $f7███$d█$t + $f1███$d█$t $f2███$d█$t $f3███$d█$t $f4███$d█$t $f5███$d█$t $f6███$d█$t $f7███$d█$t + $d$f1 ▀▀▀ $f2▀▀▀ $f3▀▀▀ $f4▀▀▀ $f5▀▀▀ $f6▀▀▀ $f7▀▀▀ +EOF