aboutsummaryrefslogtreecommitdiff
path: root/.local/bin/tsarbar_status.sh
blob: dce159fdd614fee9d55fabfcad55476793834b1c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#! /bin/bash

tsarc config -font "CommitMono:pixelsize=15"
tsarc config -height 17
tsarc config -bg "#000000"
tsarc config -gap 10

tsarc set ~ -text "|"
tsarc set window -bg "#202020"
tsarc set window -margin 25

tsarc layout -left workspace -center window -right ram ~ vol ~ clock

trap "pkill -P $$" INT

workspace() {
  focused_ws=`bspc query -D --names -d focused`
  ws=`bspc query -D --names | tr '\n' ' ' | sed s/$focused_ws/$focused_ws\*/`
  tsarc set workspace -text " $ws"
}

window_name() {
  win_id=$(bspc query -N -n focused)
  if [[ -n "$win_id" ]]; then
    title=$(xtitle $win_id)
    tsarc set window -text "$title"
  else
    tsarc set window -text "[...]"
  fi
}

bspc subscribe \
  desktop_focus desktop_add desktop_remove \
  node_focus node_add node_remove node_transfer \
| while read -r _; do
  workspace
  window_name
done &

while true; do
  tsarc set vol -text "VOL `pactl get-sink-volume @DEFAULT_SINK@ | awk 'NR==1{printf "%s", $5}'`"
done &

while true; do
  tsarc set clock -text "`date +"%a %b %d, %r"` "
  tsarc set ram -text "RAM `free -m | awk 'NR==2{printf "%.2f%%", $3*100/$2}'`"
  sleep 1
done