dotfiles

Obligatory dotfiles repo
git clone git://git.danielmoch.com/dotfiles.git
Log | Files | Refs

commit aa50ac2676c70e6d3b3dea1e33cbfadf58b44cc3
parent 5bd15fe49d43cbca86a894be9e5892fc8bb5152b
Author: Daniel Moch <daniel@danielmoch.com>
Date:   Fri, 26 Jan 2018 08:43:40 -0500

Add battery and weather to status bars

Diffstat:
M.config/awesome/rc.lua | 10+++-------
M.config/i3/config | 4++--
M.config/i3status/config | 11+++--------
M.config/tmux/bin/battery_indicator.sh | 27+--------------------------
M.local/bin/my | 74+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---
5 files changed, 80 insertions(+), 46 deletions(-)

diff --git a/.config/awesome/rc.lua b/.config/awesome/rc.lua @@ -126,11 +126,8 @@ menubar.utils.terminal = terminal -- Set the terminal for applications that requ -- }}} -- {{{ Wibar --- Keyboard map indicator and switcher -mykeyboardlayout = awful.widget.keyboardlayout() - --- Create a textclock widget -mytextclock = wibox.widget.textclock() +-- Create a status widget +mystatus = awful.widget.watch('my status', 15) -- Create a wibox for each screen and add it local taglist_buttons = gears.table.join( @@ -234,9 +231,8 @@ awful.screen.connect_for_each_screen(function(s) s.mytasklist, -- Middle widget { -- Right widgets layout = wibox.layout.fixed.horizontal, - mykeyboardlayout, + mystatus, wibox.widget.systray(), - mytextclock, s.mylayoutbox, }, } diff --git a/.config/i3/config b/.config/i3/config @@ -84,7 +84,7 @@ bindsym $mod+Shift+7 move container to workspace 7 bindsym $mod+Shift+8 move container to workspace 8 bindsym $mod+Shift+9 move container to workspace 9 -bindsym $mod+Control+r reload +bindsym $mod+Control+r restart # }}} # {{{ Resize Mode @@ -103,7 +103,7 @@ mode "resize" { bar { position top tray_output primary - status_command i3status + status_command eval my i3status colors { background $background diff --git a/.config/i3status/config b/.config/i3status/config @@ -7,17 +7,12 @@ # If the above line is not correctly displayed, fix your editor first! general { - colors = true - interval = 5 + colors = true + interval = 5 } -order += "battery all" order += "tztime local" -battery all { - format = "%status %percentage %remaining" -} - tztime local { - format = "%Y-%m-%d %H:%M" + format = "%l:%M %p" } diff --git a/.config/tmux/bin/battery_indicator.sh b/.config/tmux/bin/battery_indicator.sh @@ -3,32 +3,7 @@ SMILE='☻ ' -uname=$(uname -s) - -case $uname in - *Linux*) - if [[ $(acpi | wc -l) -eq 2 ]] - then - current_charge=$(acpi | awk 'getline' | awk '{print $4}' | sed 's~%~~' | sed 's~,~~') - else - current_charge=$(acpi | awk '{print $4}' | sed 's~%~~' | sed 's~,~~') - fi - total_charge=100 - ;; - *Darwin*) - battery_info=`ioreg -rc AppleSmartBattery` - current_charge=$(echo $battery_info | grep -o '"CurrentCapacity" = [0-9]\+' | awk '{print $3}') - total_charge=$(echo $battery_info | grep -o '"MaxCapacity" = [0-9]\+' | awk '{print $3}') - ;; - *CYGWIN*) - current_charge=$(wmic path Win32_Battery Get EstimatedChargeRemaining /format:list 2>/dev/null | grep '[^[:blank:]]' | cut -d= -f2) - total_charge=100 - ;; - *) - echo "no battery status" -esac - -charged_slots=$(echo "((($current_charge/$total_charge)*10)/3)+1" | bc -l | cut -d '.' -f 1) +charged_slots=$(echo "`my battery percent`/30+1" | bc -l | cut -d '.' -f 1) if [[ $charged_slots -gt 3 ]]; then charged_slots=3 fi diff --git a/.local/bin/my b/.local/bin/my @@ -153,7 +153,7 @@ case $command in numoptions=`echo $xrandr_options | wc -w` if [ $numoptions -eq 1 ] then - __mylog "my screen" "Executing xrandr --output $xrandr_options --auto" + __mylog "my screen" "Executing xrandr --output $xrandr_options --auto --primary" xrandr --output $xrandr_options --auto --primary else # Prefer external monitors @@ -167,8 +167,8 @@ case $command in [ -n "$primary_found" ] && selection=$option && break done - __mylog "my screen" "Executing xrandr --output $selection --auto" - xrandr --output $selection --auto + __mylog "my screen" "Executing xrandr --output $selection --auto --primary" + xrandr --output $selection --auto --primary for option in $xrandr_options do @@ -202,4 +202,72 @@ case $command in __mylog "my brightness" "No handler found" fi ;; + battery) + uname=`uname -s` + + case $1 in + remaining) + case $uname in + *Linux*) + if [ `acpi | wc -l` -eq 2 ] + then + acpi | awk 'getline' | awk '{print $4}' | sed 's~%~~' | sed 's~,~~' + else + acpi | awk '{print $4}' | sed 's~%~~' | sed 's~,~~' + fi + ;; + *Darwin*) + battery_info=`ioreg -rc AppleSmartBattery` + echo $battery_info | grep -o '"CurrentCapacity" = [0-9]\+' | awk '{print $3}' + ;; + *CYGWIN*) + wmic path Win32_Battery Get EstimatedChargeRemaining /format:list 2>/dev/null | grep '[^[:blank:]]' | cut -d= -f2 + ;; + *) + echo "no battery status" + exit 1 + esac + exit 0 + ;; + total) + case $uname in + *Linux*|*CYGWIN*) + echo 100 + ;; + *Darwin*) + battery_info=`ioreg -rc AppleSmartBattery` + echo $battery_info | grep -o '"MaxCapacity" = [0-9]\+' | awk '{print $3}' + ;; + *) + echo "no battery status" + exit 1 + esac + exit 0 + ;; + percent) + echo "`my battery remaining`/`my battery total` * 100" | bc -l | cut -d '.' -f 1 + exit 0 + ;; + esac + ;; + status) + echo -n "Batt: `my battery percent`% | " + cat $HOME/.config/forecastio/current_forecast.txt + echo -n " | " + [ -z "$1" ] && date +'%l:%M %p' + exit 0 + ;; + i3status) + if type i3status > /dev/null 2>&1 + then + i3status | while : + do + read line + echo "`my status noclock` $line" || exit 1 + done + else + __mylog "my i3status" "i3status not found" + exit 1 + fi + ;; esac