diff options
| author | Mitch Riedstra <mitch@riedstra.us> | 2020-11-01 13:34:40 -0500 |
|---|---|---|
| committer | Mitch Riedstra <mitch@riedstra.us> | 2020-11-01 22:22:13 -0500 |
| commit | 55d75452c658f2a46c439d0d632b626f1889b612 (patch) | |
| tree | 8716ad9996fbff8191751b77fe465aebf412abb0 | |
| parent | b8d5cf5b393c6373b3dbfa5b1baf3e527de3e05b (diff) | |
| download | dotfiles-55d75452c658f2a46c439d0d632b626f1889b612.tar.gz dotfiles-55d75452c658f2a46c439d0d632b626f1889b612.tar.xz | |
Add backlight script. Also add status-bar and update my git configuration.
| -rw-r--r-- | bin/Makefile | 6 | ||||
| -rwxr-xr-x | bin/backlight | 14 | ||||
| -rwxr-xr-x | bin/status-bar | 77 | ||||
| -rw-r--r-- | gitconfig/mitch | 2 |
4 files changed, 99 insertions, 0 deletions
diff --git a/bin/Makefile b/bin/Makefile index ac77c59..a66fbff 100644 --- a/bin/Makefile +++ b/bin/Makefile @@ -1,4 +1,8 @@ +default: install + +linux: + install backlight $(HOME)/bin install: install -d $(HOME)/bin @@ -9,3 +13,5 @@ install: install day $(HOME)/bin/ install night $(HOME)/bin/ install wallpaper $(HOME)/bin/ + install status-bar $(HOME)/bin/ + diff --git a/bin/backlight b/bin/backlight new file mode 100755 index 0000000..4df3636 --- /dev/null +++ b/bin/backlight @@ -0,0 +1,14 @@ +#!/bin/sh +set -e +set -x +# Note the trailing slash +# base="/sys/class/backlight/amdgpu_bl0/" +base="/sys/class/backlight/intel_backlight/" +_backlight="${base}brightness" +_max="${base}max_brightness" +_max="$(cat "$_max" | awk '{print $1/100;}')" + +percent="$(echo "$1" | awk '{print int($1*'"$_max"');}')" + +sudo sh -c "echo \"$percent\" > $_backlight" + diff --git a/bin/status-bar b/bin/status-bar new file mode 100755 index 0000000..f0523ae --- /dev/null +++ b/bin/status-bar @@ -0,0 +1,77 @@ +#!/bin/sh +timeout=5 + +_sys_memory() { + free -m | awk '/^Mem/{print $6;exit 0;}' +} + +_sys_uptime() { +uptime | sed -re's/^.*up[ ]+//g' -e's/^([^,]*),.*/\1/g' -e's/^([^ ]+)[ ]*(.).*/\1\2/g' +} + +wireless_info() { + _if="$1" + + printf "WiFi: %s %s %s %s" \ + "$_if" \ + "$(nmcli c | awk "/$_if/"'{print $1}')" \ + "$(ip -4 addr show dev "$_if" | awk '/inet /{print $2}')" \ + "$(awk '/^wlp3s0/{print $4+0}' /proc/net/wireless)dbm" +} + +eth_info() { + _if="$1" + + printf "Eth: %s %s %s" \ + "$_if" \ + "$(ip -4 addr show dev "$_if" | awk '/inet /{print $2}')" \ + "" + + # "$(ifconfig "$_if" | grep -oE '[0-9]+baseT')" +} + +network_info() { + # default_if="$(netstat -rnf inet | awk '/^default/{print $8}')" + default_if="$(ip route | awk '/^default/{print $5;exit 0;}')" + + if [ -z "$default_if" ] ; then + echo "No conn" + elif [ -d "/sys/class/net/$default_if/wireless" ] ; then + wireless_info "$default_if" + else + eth_info "$default_if" + fi +} + + +ac_status() { + sudo tlp-stat -b | awk '/\/status/{print $3}' +} + +cpu_freq() { +cat /proc/cpuinfo | grep '^cpu MHz' | awk '{print $4}' | sort -nr | sed 1q +} + +status_line() { +echo \ +"Temp: $(sensors | sed -n 's/^temp1:[\t ]*//p' | sed 's/ *//g' | sed 1q | tr -d '\n')|"\ +"Fan: $(sensors | sed -n 's/^fan1:[\t ]*//p')|"\ +"Cpu Freq: $(cpu_freq)mhz|"\ +"Batt: $(sudo tlp-stat -b | awk '/^Charge/{print $3}') $(ac_status)|"\ +"$(network_info)|"\ +"Free Mem: $(_sys_memory)|"\ +"Uptime: $(_sys_uptime)|"\ +"$(date '+%m.%d.%Y %H:%M:%S')" +} + +x230() { +while true ; do + +xsetroot -name "$(status_line)" + +sleep "$timeout" +done +} + + +$@ diff --git a/gitconfig/mitch b/gitconfig/mitch index 7eba35e..2d66968 100644 --- a/gitconfig/mitch +++ b/gitconfig/mitch @@ -7,3 +7,5 @@ [alias] hist = log --pretty=format:'%h %ad | %s%d [%an]' --graph --date=short histv = log --pretty=format:'%h %ad | %s%d [%an]' --graph --date=short --stat +[pull] + ff = only |
