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

PrimalZurvan (scrot)

szorfein Jun 06, 2016 (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
#! /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

$(dirname $0)/panel &

CLICK TO VIEW

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
#! /bin/sh

HEIGHT=24
FONT="-*-fixed-*-*-*-*-12-*-*-*-*-*-*-*"
FONT_ICON="-wuncon-siji-medium-r-normal--10-100-75-75-c-80-iso10646-1"
WM_NAME="Bspwm"

# icons
CSTART="\ue00d"
CSOUND="\ue04d"
CVOLUME="\ue11b"
CMAIL="\ue070"
CRAM="\ue19a"
CCPU="\ue1c1"
CNET="\ue04b"
CWIFI="\ue222"
CFULL="\ue056"
CNONE="\ue0e6"
CCLOCK="\ue016"
CTIME="\ue018"
CPACK="\ue1b7"
# icons panel music
CPREV="\ue055"
CNEXT="\ue05b"
CPLAY="\ue058"
CPAUS="\ue059"
# battery or AC
BAT100="\ue254"
BAT70="\ue252"
BAT50="\ue250"
BAT30="\ue24f"
BAT15="\ue24e"
BAT7="\ue24c"
CAC="\ue215"

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

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

# $(pText ${color} ${text})
pText() {
    echo -n "%{F$1}$2%{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

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
#! /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=$(pIcon ${RED2} ${CSTART})
        local cmd=$(uname -n)
        local clr=$(pText ${WHITE2} "${cmd}")
        echo ${ic}$SEP${clr}
    }

    panelMusic() {
        local icp=$(pAction $WHITE2 $RED "mpc prev &>/dev/null" ${CPREV})
        local icn=$(pAction $WHITE2 $RED "mpc next &>/dev/null" ${CNEXT})
        local icpl=$(pAction $WHITE2 $RED "mpc play &>/dev/null" ${CPLAY})
        local icpa=$(pAction $WHITE2 $RED "mpc pause &>/dev/null" ${CPAUS})
        echo "$icp $icn $icpl $icpa"
    }

    music() {
        local ic=$(pIcon ${RED2} ${CSOUND})
        local status=$(mpc current)
        if [ "$status" != "" ] ; then
            local artist=$(mpc -f %artist% current)
            local musicname=$(mpc -f %title% current)
            local clr1=$(pText ${BLUE2} "${artist}")
            local clr2=$(pText ${CYAN2} "${musicname:0:20}")
            echo ${ic}$SEP${clr1}$SEP${clr2}
        else
            echo ${ic}$SEP%{F${RED}}No Sound%{F-}
        fi
    }

    volume() {
        local ic=$(pIcon ${RED2} ${CVOLUME})
        local cmd=$(mpc volume | awk '{FS:":"}{print $2}' | sed -e 's/\%//g')
        local cmd+="$SEP%$SEP"
        local clr=$(pText ${YELLOW} "${cmd}")
        echo ${ic}$SEP${clr}
    }

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

} > "$PANEL_FIFO" &

# Top Right
{
    getDay() {
        local ic=$(pIcon ${RED} ${CTIME})
        local cmd=$(date '+%A %d %b')
        local clr=$(pText ${GREEN2} "${cmd}")
        echo ${ic}$SEP${clr}
    }

    clock() {
        local ic=$(pIcon ${RED2} ${CCLOCK})
        local cmd=$(date +%H:%M)
        local clr=$(pText ${YELLOW} "${cmd}")
        echo ${ic}$SEP${clr}
    }

    mail() {
        local gmaildir=$HOME/.mails/Gmail/\[Gmail\].All\ Mail/new
        local ic=$(pIcon ${RED2} ${CMAIL})
        local count=0
        if [[ ! -n $(ls "${gmaildir}") ]]; then
            count=0
        else
            count=$(ls -1 "${gmaildir}" | wc -l)
        fi
        echo ${ic}$SEP${count}
    }

    net() {
        local ic=$(pIcon ${RED2} ${CNET})
        local dev=$(ip route | grep link | awk '{print $3}')
        local clr=$(pText ${CYAN2} "${dev}")
        echo ${ic}$SEP${clr}
    }

    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 ${RED2} $icon)$SEP$(pText ${WHITE} ${batCap})"
    }

    ram() {
        local ic=$(pIcon ${RED2}} ${CRAM})
        local cmd=$(free -m | grep Mem | awk '{print $3}')
        local clr=$(pText ${MAGENTA2} "${cmd}")
        echo ${ic}$SEP${clr}
    }

    cpu() {
        local ic=$(pIcon ${RED2} ${CCPU})
        local cmd=$(cat /proc/loadavg | awk '{print $1}')
        cmd+=$SEP$(cat /proc/cpuinfo | grep -i mhz |awk '{ORS=" "}{print $4}'| sed -e 's/.000//g')
        local clr=$(pText ${WHITE} "${cmd}")
        echo ${ic}$SEP${clr}
    }

    package() {
        local cmd=$(equery list "*" | wc -l)
        echo $(pIcon ${RED2} ${CPACK})$SEP$(pText ${YELLOW2} "${cmd}")
    }

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

} > "$PANEL_FIFO" &

$(dirname $0)/panel_bar < "$PANEL_FIFO" | lemonbar \
    -a 32 \
    -g x$HEIGHT \
    -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_bar(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=${WHITE}
                                BG=${BG}
								;;
							M*)
								# focused monitor
                                FG=${WHITE}
                                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=${WHITE}
                                IC=${CNONE}
                                BG=${BG}
								;;
							F*)
								# focused free desktop
                                FG=${RED}
                                IC=${CNONE}
                                BG=${BG}
								;;
							o*)
								# occupied desktop
                                FG=${CYAN}
                                IC=${CFULL}
                                BG=${BG}
								;;
							O*)
								# focused occupied desktop
                                FG=${RED2}
                                IC=${CFULL}
                                BG=${BG}
								;;
							u*)
								# urgent desktop
                                FG=${WHITE2}
                                BG=${RED}
                                IC=${CNONE}
								;;
							U*)
								# focused urgent desktop
                                FG=${BLACK}
                                BG=${RED}
                                IC=${CNONE}
								;;
						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${YELLOW}}%{B${BLACK}} ${name} %{B-}%{F-}"
						;;
				esac
				shift
			done
			;;
	esac
	printf "%s\n" "%{l}${sysL}%{c}${wm}%{r}${sysR}"
done
 

x