all repos — dotfiles @ ecbbff5a215a337ea000a2cc2a9755f5a6365e87

my *nix dotfiles

polybar: Custom scripts for bat, time, vol

Signed-off-by: Anirudh Oppiliappan <x@icyphox.sh>
Anirudh Oppiliappan x@icyphox.sh
Fri, 13 Sep 2019 21:38:41 +0530
commit

ecbbff5a215a337ea000a2cc2a9755f5a6365e87

parent

b713e693974c794d686f2efa65f23511fb98d2d9

5 files changed, 73 insertions(+), 33 deletions(-)

jump to
A bin/bat.sh

@@ -0,0 +1,14 @@

+#!/usr/bin/env bash + +fg="$(xres color0)" +light="$(xres color8)" + +cap=$(cat /sys/class/power_supply/BAT0/capacity) +status=$(cat /sys/class/power_supply/BAT0/status) + +if [[ "$status" = "Charging" ]] +then + echo -ne "%{F$light}+bat %{F$fg}$cap%" +else + echo -ne "%{F$light}bat %{F$fg}$cap%" +fi
A bin/time.sh

@@ -0,0 +1,18 @@

+#!/usr/bin/env bash + +fg="$(xres color0)" +light="$(xres color8)" + +date="%{F$light}time%{F$fg} $(date +%I:%M)" +time="%{F$light}date %{F$fg}$(date +"%a, %d %b" | tr A-Z a-z)" + +while getopts dt options +do + case $options in + d) + echo -ne "$date" + ;; + t) + echo -ne "$time" + esac +done
A bin/vol.sh

@@ -0,0 +1,21 @@

+#!/usr/bin/env bash + +fg="$(xres color0)" +light="$(xres color8)" + +while getopts idq options +do + case $options in + i) + amixer sset Master 2%+ + ;; + + d) + amixer sset Master 2%- + ;; + q) + cur_vol=$(amixer get Master | grep 'Right' | awk -F'[][]' '{ print $2 }' | tr -d '\n') + echo -ne "%{F$light}vol %{F$fg}$cur_vol" + ;; + esac +done
A bin/xres

@@ -0,0 +1,4 @@

+#!/usr/bin/env bash +# stolen from nerdy + +xrdb -query | grep -w $1 | awk '{print $2}'
M config/polybar/barconfig/polybar/bar

@@ -31,9 +31,9 @@ foreground = ${colors.fg}

font-0 = SF Mono:size=12:weight=semibold;3 -modules-left = date time volume battery ewmh +modules-left = date time volume battery modules-center = -modules-right = xwindow +modules-right = ewmh tray-position = false tray-padding = 0

@@ -49,15 +49,11 @@ module-margin-left = 2

module-margin-right = 2 [module/volume] -type = internal/alsa - -format-volume = <label-volume> -label-volume = vol %percentage%% -module-margin-right = 1 - -format-volume-background = ${colors.bg} -label-muted = muted - +type = custom/script +interval = 0.01 +exec = ~/bin/vol.sh -q +scroll-up = ~/bin/vol.sh -i +scroll-down = ~/bin/vol.sh -d [module/xwindow] type = internal/xwindow

@@ -90,33 +86,20 @@ label-urgent-foreground = #EC5f67

label-urgent-background = ${colors.bg} label-urgent-padding = 1 - [module/date] -type = internal/date -interval = 1 -date = %a, %d %b -format-prefix-foreground = ${xrdb:color6} +type = custom/script +interval = 1.0 +exec = ~/bin/time.sh -d [module/time] -type = internal/date -interval = 1 -date = %I:%M -format-prefix-foreground = ${xrdb:color6} +type = custom/script +interval = 1.0 +exec = ~/bin/time.sh -t [module/battery] -type = internal/battery -full-at = 100 -battery = BAT0 -adapter = ACAD -poll-interval = 5 - -format-charging = <label-charging> -format-discharging = <label-discharging> -label-charging = bat+ %percentage%% -label-charging-foreground = ${colors.fg} -label-discharging = bat %percentage%% -label-discharging-foreground = ${colors.fg} -label-full = full! +type = custom/script +interval = 1.0 +exec = ~/bin/bat.sh [module/spotipy] type = custom/script