guest@dotshare [~/groups/wms/bspwm] $ ls whisper/ | cat

whisper (scrot) (+2 likes)

szorfein Jan 06, 2017 (wms/bspwm)

bspwmrc(raw, dl)

SCROT

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#! /bin/sh

source $(dirname $0)/config

sxhkd &

bspc config border_width            2
bspc config window_gap              7

bspc config split_ratio             0.5
bspc config borderless_monocle      true
bspc config gapless_monocle         true
bspc config focus_by_distance       true
bspc config history_aware_focus     true
bspc config focus_follows_pointer   true
bspc config presel_feedback_color   ${BG}

bspc monitor -d i ii iii iv vi vii

bspc rule -a sxiv follow=off state=flaoting 
bspc rule -a mpv follow=off state=floating

$(dirname $0)/panel &

CLICK TO VIEW

x

panel(raw, dl)

  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
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
#! /bin/sh

source $(dirname $0)/config
    
if xdo id -a "$WM_NAME" > /dev/null ; then
    printf "%s\n" "The panel is already running." >&2
    exit 1
fi

trap 'trap - TERM; kill 0' INT TERM QUIT EXIT

[ -e "$PANEL_FIFO" ] && rm "$PANEL_FIFO"
mkfifo "$PANEL_FIFO"

bspc config top_padding $HEIGHT
bspc subscribe |\
    grep -oE "[Mm][^TM]*[TML]" --line-buffered |\
    while read line; do echo W$line; done > "$PANEL_FIFO" &

# Top left
{
    getName() {
        local ic=$(pIconUnderline ${BLACK2} ${GREEN} ${GENTOO})
        local cmd="$(uname -n)"
        local clr=$(pTextUnderline ${WHITE} ${GREEN} " ${cmd}")
        echo " ${ic}${clr}"
    }

    panelMusic() {
        local prev=$(pAction $FG $BG "mpc prev &>/dev/null" ${CPREV})
        local pause=$(pAction $FG $BG "mpc pause &>/dev/null" ${CPAUS})
        local play=$(pAction $FG $BG "mpc play &>/dev/null" ${CPLAY})
        local next=$(pAction $FG $BG "mpc next &>/dev/null" ${CNEXT})
        echo "${prev}${pause}${play}${next}"
    }

    music() {
        local icon=$(pIconUnderline ${RED2} ${BLUE} ${CSOUND})
        local stat="$(mpc status | grep \# | awk '{print $1}')"
        local artist=$(mpc -f %artist% current)
        local musicname=$(mpc -f %title% current)
        local cmd=""

        if [ "${stat}" ] && [ "${stat}" = "[playing]" ] ; then
            cmd=" Playing >> ${artist:0:10} - ${musicname:0:15}"
        elif [ "${stat}" ] && [ "${stat}" = "[paused]" ] ; then
            cmd=" Paused >> ${artist:0:10} - ${musicname:0:15}"
        else
            cmd="No Sound"
        fi
        
        echo "${icon}$(pTextUnderline ${WHITE} ${BLUE} "${cmd}")"
    }

    volume() {
        local icon=$(pIcon ${CYAN2} ${CVOLUME})
        local volume="$(mpc volume | awk '{print $2}')"
        [[ -z ${volume%?} ]] && volume='100%'
        local clr=$(pText ${MAGENTA2} "${volume}")
        local plus=$(pAction $FG $BG "mpc volume +4 &>/dev/null" ${VPLUS})
        local minus=$(pAction $FG $BG "mpc volume -3 &>/dev/null" ${VMINUS})

        echo "${icon} ${clr} ${plus}${minus}"
    }

    while :; do
        echo "T$(getName) $(panelMusic) $(music) $(volume)"
        sleep 5
    done

} > "$PANEL_FIFO" &

# Top Right
{
    getDay() {
        local icon=$(pIconUnderline ${BLACK2} ${GREEN} ${CTIME})
        local cmd=" $(date '+%A %d %b')" 
        local clr=$(pTextUnderline ${WHITE} ${GREEN} "${cmd}")
        echo "${icon}${clr}"
    }

    clock() {
        local icon=$(pIcon ${GREEN2} ${CCLOCK})
        local cmd=$(date +%H:%M)
        local clr=$(pText ${FG} "${cmd}")
        echo "${icon} ${clr}"
    }

    mail() {
        local gmaildir=/home/user/mails/Gmail-User/\[Gmail\].All\ Mail/new
        local prog=$(pAction $FG $BG "termite -e mutt" ${CMAIL})
        local icon=$(pIcon ${CYAN} ${CMAIL})
        local count=0
        if [[ ! -n $(ls "${gmaildir}") ]]; then
            count=0
        else
            count=$(ls -1 "${gmaildir}" | wc -l)
        fi
        echo "${prog} ${count}"
    }

    net() {
        local _GETIWL=$(/sbin/iwgetid -r)
        local _GETETH=$(ip a | grep "state UP" | awk '{ORS=""}{print $2}' | cut -d ':' -f 1)
        local _status=${_GETIWL:-$_GETETH}
        local _status2="${_status:-Down}"
        local icon="$(pIconUnderline ${CYAN2} ${MAGENTA2} ${CNET})"
        local cmd=$(pTextUnderline ${WHITE} ${MAGENTA2} " ${_status2}")

        echo "${icon}${cmd}"
    } 

    energy() {
        local ac=/sys/class/power_supply/AC/online
        local bat=/sys/class/power_supply/BAT0/present
        local icon=""
        local batCap=""
        if [[ -e $bat ]] && [[ $(cat $ac) -lt 1 ]]; then
            batCap="$(cat ${bat%/*}/capacity)"
            [ $batCap -gt 90 ] && icon=$BAT100
            [ $batCap -gt 70 ] && [ $batCap -lt 90 ] && icon=$BAT70
            [ $batCap -gt 50 ] && [ $batCap -lt 70 ] && icon=$BAT50
            [ $batCap -gt 30 ] && [ $batCap -lt 50 ] && icon=$BAT30
            [ $batCap -gt 15 ] && [ $batCap -lt 30 ] && icon=$BAT15
            [ $batCap -lt 7 ] && icon=$BAT7
        elif [[ -n $(cat $ac) ]]; then
            batCap="AC"
            icon=$CAC
        else
            batCap="wttf"
        fi
        echo "$(pIcon ${CYAN2} $icon) $(pText ${MAGENTA} ${batCap})"
    }

    ram() {
        local icon=$(pIcon ${CYAN} ${CRAM})
        local cmd=$(free -m | grep Mem | awk '{print $3}')
        cmd+=" Mb"
        local clr=$(pText ${FG} "${cmd}")
        echo "${icon} ${clr}"
    }

    # Cpu List Load, number of Process and actual MHz frequency.
    cpu() {
        local icon=$(pIconUnderline ${GREEN} ${MAGENTA} ${CCPU})
        local cmd=" $(cat /proc/loadavg | awk '{print $1}')"
        local cmd+=" $(cat /proc/loadavg | awk '{print $4}')"
        local cmd+=" $(cat /proc/cpuinfo| grep MHz | awk '{ORS=" "}{print $4}' | sed -e 's/.000//g' | cut -f 1)"

        local clr=$(pTextUnderline ${WHITE} ${MAGENTA} "${cmd}")
        echo "${icon}${clr}"
    }

    # On archlinux, change cmd=$(pacman -Ql | wc -l), or remove it complety.
    #package() {
    #    local icon=$(pIcon ${GREEN} ${CPACK})
    #    local cmd=$(equery list "*" | wc -l)
    #    local clr=$(pText ${MAGENTA} "${cmd}")
    #    echo "${icon} ${clr}"
    #}

    while :; do
        #echo "S$(package) $(cpu) $(ram) $(energy) $(net) $(mail) $(clock) $(getDay)"
        echo "S$(cpu) $(ram) $(energy) $(net) $(mail) $(clock) $(getDay)"
        sleep 5
    done

} > "$PANEL_FIFO" &

$(dirname $0)/panel_bar < "$PANEL_FIFO" | lemonbar \
    -a 32 \
    -n "$WM_NAME" \
    -g x$HEIGHT \
    -u 2 \
    -f "$FONT" \
    -f "$FONT_ICON" \
    -F "$FG" \
    -B "$BG" | sh | while read line; do eval "$line"; done &

wid=$(xdo id -a "$WM_NAME")
tries_left=20

while [ -z "$wid" -a "$tries_left" -gt 0 ] ; do
	sleep 0.05
	wid=$(xdo id -a "$WM_NAME")
	tries_left=$((tries_left - 1))
done

[ -n "$wid" ] && xdo above -t "$(xdo id -N Bspwm -n root | sort | head -n 1)" "$wid"

wait
 

x

panel(raw, dl)

 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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#! /bin/sh

source $(dirname $0)/config

num_mon=$(bspc query -M | wc -l)

while read -r line ; do
    case $line in
        S*)
            # clock output
            sysR="${line#?}"
            ;;
		T*)
			# xtitle output
            sysL="${line#?}"
			;;
		W*)
			# bspwm's state
			wm=""
			IFS=':'
			set -- ${line#?}
			while [ $# -gt 0 ] ; do
				item=$1
				name=${item#?}
				case $item in
					[mM]*)
						[ $num_mon -lt 2 ] && shift && continue
						case $item in
							m*)
								# monitor
                                FG=${FG}
                                BG=${BG}
								;;
							M*)
								# focused monitor
                                FG=${FG}
                                BG=${BG}
								;;
						esac
                        wm="${wm}%{F${FG}}%{B${BG}}%{A:bspc monitor -f ${name}:} ${name} %{A}%{B-}%{F-}"
						;;
					[fFoOuU]*)
						case $item in
							f*)
								# free desktop
                                FG=${MAGENTA}
                                IC=${CNONE}
                                BG=${BG}
								;;
							F*)
								# focused free desktop
                                FG="#846774"
                                IC=${CNONE}
                                BG=${BG}
								;;
							o*)
								# occupied desktop
                                FG="#678b7b"
                                IC=${CFULL}
                                BG=${BG}
								;;
							O*)
								# focused occupied desktop
                                FG="#846774"
                                IC=${CFULL}
                                BG=${BG}
								;;
							u*)
								# urgent desktop
                                FG=${GREEN2}
                                IC=${CNONE}
                                BG=${BG}
								;;
							U*)
								# focused urgent desktop
                                FG=${RED2}
                                IC=${CFULL}
                                BG=${BG}
								;;
						esac
                        wm="${wm}%{F${FG}}%{B${BG}}%{A:bspc desktop -f ${name}:} $(printf '%b' $IC) %{A}%{B-}%{F-}"
						;;
					[LTG]*)
						# layout, state and flags
                        wm="${wm}%{F${FG}}%{B${BG}} ${name} %{B-}%{F-}"
						;;
				esac
				shift
			done
			;;
	esac
	printf "%s\n" "%{l}${sysL}%{c}${wm}%{r}${sysR}"
done
 

x

config(raw, dl)

 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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#! /bin/sh
 
HEIGHT=26
#FONT="-*-fixed-medium-*-*-*-10-*-*-*-*-*-*-*"
FONT="-*-dina-medium-r-*-*-10-*-*-*-*-*-*-*"
FONT_ICON="-wuncon-siji-medium-r-normal--10-100-75-75-c-80-iso10646-1"
WM_NAME="Bspwm"

# icons
GENTOO="\ue0a0"
ARCH="\ue00e"
CSTART="\ue00d"
CSOUND="\ue04d"
CVOLUME="\ue204"
CMAIL="\ue070"
CRAM="\ue19a"
CCPU="\ue021"
CNET="\ue04b"
CWIFI="\ue222"
# Time
CTIME="\ue018"
CPACK="\ue1b7"
CCLOCK="\ue016"
# panel center
CNONE="\ue001"
CFULL="\ue000"
# icons panel music
CPREV="\ue055"
CNEXT="\ue05b"
CPLAY="\ue058"
CPAUS="\ue059"
# icon volume
VPLUS="\ue06c"
VMINUS="\ue06d"
# battery or AC
BAT100="\ue254"
BAT70="\ue252"
BAT50="\ue250"
BAT30="\ue24f"
BAT15="\ue24e"
BAT7="\ue24c"
CAC="\ue215"

# $(pAction ${fg} ${bg} ${${command} ${whatprint})
pAction() {
    echo "%{F$1}%{B$2}%{A:$3:}$(printf '%b' $4)%{A}%{B-}%{F-}"
}

# $(pActionUnderline ${fg} ${bg} ${underline} ${${command} ${whatprint})
pActionUnderline() {
    echo "%{F$1}%{B$2}%{U$3}%{+u}%{A:$4:}$(printf '%b' $5)%{A}%{-u}%{B-}%{F-}"
}

# $(pIcon ${color} ${icon})
pIcon() {
    echo "%{F$1}$(printf '%b' $2)%{F-}"
}

# $(pIconUnderline ${color} ${color_underline} ${icon})
pIconUnderline() {
    echo "%{F$1}%{U$2}%{+u}$(printf '%b' $3)%{-u}%{F-}"
}

# $(pText ${color} ${text})
pText() {
    echo "%{F$1}$2%{F-}"
}

# $(pTextUnderline ${color} ${color_underline} ${text})
pTextUnderline() {
    echo "%{F$1}%{U$2}%{+u}$3%{-u}%{F-}"
}

getXresColor() {
   echo "$( xrdb -query | grep $1: | grep -oE '#[a-zA-Z0-9]{6}' | cut -c 1- )"
}

# colors
BLACK="$(getXresColor color0)"
BLACK2="$(getXresColor color8)"
RED="$(getXresColor color1)"
RED2="$(getXresColor color9)"
GREEN="$(getXresColor color2)"
GREEN2="$(getXresColor color10)"
YELLOW="$(getXresColor color3)"
YELLOW2="$(getXresColor color11)"
BLUE="$(getXresColor color4)"
BLUE2="$(getXresColor color12)"
MAGENTA="$(getXresColor color5)"
MAGENTA2="$(getXresColor color13)"
CYAN="$(getXresColor color6)"
CYAN2="$(getXresColor color14)" 
WHITE="$(getXresColor color7)"
WHITE2="$(getXresColor color15)"

BG="$(getXresColor background)"
FG="$(getXresColor foreground)"

SEP=" "
 

x

Xresource(raw, dl)

 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
!-----------------------------------------------------------
! General Color

*background:    #23232d
*foreground:    #7c7c7e
*.cursorColor:  #2a2a20

!black
*color0: #24181c
*color8: #49393f
!red
*color1: #551c2c
*color9: #782e43
!green
*color2: #396248
*color10: #578c6a
!yellow
*color3: #b3873d
*color11: #cba360
!blue
*color4: #4b5f84
*color12: #6b7993
!magenta
*color5:  #6a394f
*color13: #87556b
!cyan
*color6: #384752
*color14:  #4f6373
!white
*color7:  #b0a9ab
*color15: #dfd9db

!-------------------------------------------
! rofi

rofi.lines:                         6
rofi.color-enabled:                 true
rofi.separator-style:               none 
rofi.width:                         40
! rofi state:                          'bg'  'fg'  'bgalt'  'hlbg'  'hlfg'
rofi.color-normal:                  argb:0016141a, #9e9f9a, argb:00101011, #2f2938, #f8f8f2
rofi.color-urgent:                  argb:0016141a, #9e9f9a, argb:00101011, #2f2938, #f8f8f2
rofi.color-active:                  argb:0016141a, #9e9f9a, argb:00101011, #2f2938, #a6e22a
rofi.color-window:                  argb:ce16141a, #111111, #000000
 

x

Notes