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 be0963df5e99558fa0d75bcbe5649c99932710bd
parent 15f40881baa5518e8420c7625cb51e4e555581d3
Author: Anders Damsgaard <anders@adamsgaard.dk>
Date:   Tue, 21 May 2019 12:26:22 +0200

Use shell-based custom status script

Diffstat:
A.local/bin/dwmstatus | 5+++++
M.local/bin/keyboard-layout-switch.sh | 10+++++-----
D.local/bin/mailstatus.sh | 40----------------------------------------
A.local/bin/sysstatus | 24++++++++++++++++++++++++
M.tmux.conf | 4++--
M.xinitrc | 2+-
6 files changed, 37 insertions(+), 48 deletions(-)

diff --git a/.local/bin/dwmstatus b/.local/bin/dwmstatus @@ -0,0 +1,5 @@ +#!/bin/sh +while true; do + xsetroot -name "$(sysstatus)" + sleep 2 +done diff --git a/.local/bin/keyboard-layout-switch.sh b/.local/bin/keyboard-layout-switch.sh @@ -1,4 +1,4 @@ -#!/usr/bin/env bash +#!/bin/sh set -e # the language is written to ./.kbd-layout @@ -8,7 +8,7 @@ layoutfile="$HOME/.kbd-layout" lang1="us" lang2="dk" -function set_language { +set_language() { echo "$1" > "$layoutfile" #pkill -RTMIN+3 i3blocks setxkbmap "$1" -option ctrl:nocaps -option altwin:swap_lalt_lwin @@ -16,16 +16,16 @@ function set_language { #notify-send "$1" } -[[ $# -gt 0 ]] && set_language "$1" && exit +[ $# -gt 0 ] && set_language "$1" && exit # write the file if it doesn't exist -if [ ! -f $layoutfile ]; then +if [ ! -f "$layoutfile" ]; then set_language "us" exit 0 fi # read the language file, and switch to the other language -currlang="$(cat $layoutfile)" +currlang=$(cat "$layoutfile") if [ "$currlang" = "$lang1" ]; then set_language "$lang2" diff --git a/.local/bin/mailstatus.sh b/.local/bin/mailstatus.sh @@ -1,40 +0,0 @@ -#!/usr/bin/env bash -set -e -maildir=~/mail -if [ ! -d $maildir ]; then - exit 0 -fi -newmails=$(find $maildir/*/{INBOX,git}/new -type f) -numbernewmails=$(echo $newmails | wc -w | sed 's/ *//') -mailboxes="$(echo $newmails | tr ' ' '\n' | sed 's/.*\/mail\///' | - sed 's/\/INBOX.*//' | sed 's/adamsgaard\/git.*/git/')" - -accounts="" -if [[ $mailboxes == *"adamsgaard"* ]]; then - accounts="${accounts}a" -fi -if [[ $mailboxes == *"git"* ]]; then - accounts="${accounts}G" -fi -if [[ $mailboxes == *"princeton"* ]]; then - accounts="${accounts}p" -fi -if [[ $mailboxes == *"noaa"* ]]; then - accounts="${accounts}n" -fi -if [[ $mailboxes == *"gmail"* ]]; then - accounts="${accounts}g" -fi -if [[ $mailboxes == *"geomail"* ]]; then - accounts="${accounts}e" -fi -if [[ $mailboxes == *"ucsd"* ]]; then - accounts="${accounts}u" -fi -if [[ $mailboxes == *"riseup"* ]]; then - accounts="${accounts}r" -fi - -if [ "$numbernewmails" -gt 0 ]; then - echo "M: ${numbernewmails} (${accounts})" -fi diff --git a/.local/bin/sysstatus b/.local/bin/sysstatus @@ -0,0 +1,24 @@ +#!/bin/sh +wlandev=wlp3s0 +battery=BAT0 + +mail=$(mailstatus | sed 's/^/ /;s/$/ |/;s/ |//') +music=$(mpc status | sed 1q | sed 's/^volume:.*$//;s/^/ /;s/$/ |/;s/ |//') +keymap=$(setxkbmap -print | sed -n '5s/^.*pc+//;5s/+.*$//;5p') +vol=$(pulsemixer --get-volume | cut -d' ' -f1) +cputemp=$(sed 's/[0-9][0-9][0-9]$//' /sys/class/thermal/thermal_zone0/temp) +cpuload=$(cut -d' ' -f1 /proc/loadavg) +batstatus=$(sed 's/Charging/+/;s/Discharging/-/' \ + /sys/class/power_supply/${battery}/status) +batlvl=$(cat /sys/class/power_supply/${battery}/capacity) +batremain=$(acpi -b | sed 's/.*\([0-9][0-9]*:[0-9][0-9]\):[0-9][0-9].*/\1/') +wlanssid=$(iwgetid -r $wlandev) +wlanquality=$(echo \ + "$(grep $wlandev /proc/net/wireless | awk '{print $3}')/70 * 100" | bc -l |\ + sed 's/\..*$//') +date=$(date +'%F %T') + +status="${mail}${music} ${keymap} | ♪ ${vol}% | CPU ${cputemp}°C ${cpuload} |\ + ${batstatus}${batlvl}% ${batremain} | ${wlanssid} ${wlanquality}% | $date" + +printf "%s" "$status" diff --git a/.tmux.conf b/.tmux.conf @@ -50,9 +50,9 @@ bind T set status off # Right section of status bar if-shell 'uname | grep -qi Darwin' "set -g status-right -\"#[fg=#81a2be]#(/usr/local/bin/mpc | head -n 1 | sed 's/volume.*$//') #[fg=cyan]#(~/bin/battery-osx) #(~/.local/bin/mailstatus.sh) #[fg=yellow]#(uptime|sed 's/.* //') #[fg=#666666]%F #[fg=#bababa]%R\"" +\"#[fg=#81a2be]#(/usr/local/bin/mpc | head -n 1 | sed 's/volume.*$//') #[fg=cyan]#(~/.local/bin/battery-osx) #(~/.local/bin/mailstatus) #[fg=yellow]#(uptime|sed 's/.* //') #[fg=#666666]%F #[fg=#bababa]%R\"" -if-shell 'uname | grep -qi Linux' "set -g status-right \"#[fg=cyan]#(~/bin/battery-linux) #(~/bin/.local/mailstatus.sh) #[fg=yellow]#(cat /proc/loadavg|awk '{print $1;}') #[fg=#666666]%F #[fg=#bababa]%R\"" +if-shell 'uname | grep -qi Linux' "set -g status-right \"#(~/.local/bin/sysstatus)\"" # Scaling of status-bar sections set -g status-right-length 40 diff --git a/.xinitrc b/.xinitrc @@ -46,7 +46,7 @@ unclutter & dunst & compton & calcurse_reminders.py 15 & -slstatus & +dwmstatus & keynav & # if changing WM, remember to change WM name in crontab