Commit 4c0792ea authored by epsi sayidina's avatar epsi sayidina

polybar

parent 57654b0b
#! /bin/sh
DIR=$(dirname "$0")
source ${DIR}/config
sxhkd 2> /dev/null &
# bspc monitor -d i ii iii iv vi vii
bspc monitor -d "一" "二" "三" "四" "五" "六" "七" "八" "九" "十"
# bspwm config
# -----------------------------------------------
bspc config border_width 3
bspc config window_gap 10
bspc config split_ratio 0.5
bs`pc config borderless_monocle true
bspc config gapless_monocle true
bspc config focus_follows_pointer true
bspc config presel_feedback_color ${BG}
bspc config top_padding 25
bspc config bottom_padding 25
# Border Colors
# -----------------------------------------------
bspc config focused_border_color "#c9c925"
bspc config active_border_color "#5c5dad"
bspc config normal_border_color "#222222"
# Rules
# -----------------------------------------------
bspc rule -a Firefox desktop=^2 floating=true
bspc rule -a Geany desktop=^3
bspc rule -a Thunar desktop=^4
bspc rule -a Gimp desktop=^5 floating=true
# panel
# -----------------------------------------------
source ${DIR}/panel &
#! /bin/bash
# bspc monitor -d chat term www archiver code media
#"$HOME"/.config/polybar/launch.sh &
#sxhkd &
# autostart
# -----------------------------------------------
xsetroot -solid "#333333" &
compton &
nitrogen --restore &
# nm-applet &
dunst 2> /dev/null &
# parcellite &
# xfce4-terminal &
# xfce4-terminal &
# firefox &
# sh -c 'sleep 10; exec geany' &
# sh -c 'sleep 15; exec thunar' &
#! /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
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-}"
}
# $(pIcon ${color} ${icon})
pIcon() {
echo "%{F$1}$(printf '%b' $2)%{F-}"
}
# $(pText ${color} ${text})
pText() {
echo "%{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=" "
#! /bin/sh
PANEL_FIFO=/tmp/panel-fifo
DIR=$(dirname "$0")
source ${DIR}/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 ${YELLOW2} ${GENTOO})
local cmd=$(uname -n)
local clr=$(pText ${WHITE} "${cmd}")
echo " ${ic} ${clr}"
}
panelMusic() {
local prev=$(pAction $BG $FG "mpc prev &>/dev/null" ${CPREV})
local pause=$(pAction $BG $FG "mpc pause &>/dev/null" ${CPAUS})
local play=$(pAction $BG $FG "mpc play &>/dev/null" ${CPLAY})
local next=$(pAction $BG $FG "mpc next &>/dev/null" ${CNEXT})
echo "${prev}${pause}${play}${next}"
}
music() {
local icon=$(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 ${FG} "${artist:0:20}")
local clr2=$(pText ${FG} "${musicname:0:20}")
echo "${icon} ${clr1} ${clr2}"
else
echo "${icon} %{F${RED}}No Sound%{F-}"
fi
}
volume() {
local icon=$(pIcon ${CYAN2} ${CVOLUME})
local cmd=$(mpc volume | awk '{print $2}' | cut -d '%' -f 1)
local cmd+=" %"
local clr=$(pText ${MAGENTA2} "${cmd}")
local plus=$(pAction $BG $FG "mpc volume +4 &>/dev/null" ${VPLUS})
local minus=$(pAction $BG $FG "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=$(pIcon ${GREEN} ${CTIME})
local cmd=$(date '+%A %d %b')
local clr=$(pText ${MAGENTA} "${cmd}")
echo "${icon} ${clr}"
}
clock() {
local icon=$(pIcon ${GREEN2} ${CCLOCK})
local cmd=$(date +%H:%M)
local clr=$(pText ${FG} "${cmd}")
echo "${icon} ${clr}"
}
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=$(pIcon ${CYAN2} ${CNET})
echo "${icon} $(pText ${FG} ${_status2})"
}
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=$(pIcon ${GREEN2} ${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=$(pText ${MAGENTA2} "${cmd}")
echo "${icon} ${clr}"
}
# On archlinux, change cmd=$(pacman -Ql | wc -l), or remove it complety.
package() {
local icon=$(pIcon ${GREEN} ${CPACK})
local cmd=$(pacman -Ql | wc -l)
local clr=$(pText ${MAGENTA} "${cmd}")
echo "${icon} ${clr}"
}
while :; do
# echo "S$(package) $(cpu) $(ram) $(energy) $(net) $(clock) $(getDay)"
echo "S$(ram) $(energy) $(net) $(clock) $(getDay)"
sleep 5
done
} > "$PANEL_FIFO" &
$(dirname $0)/panel_bar < "$PANEL_FIFO" | lemonbar \
-a 32 \
-n "$WM_NAME" \
-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
#! /bin/sh
DIR=$(dirname "$0")
source ${DIR}/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="#ac8e8e"
IC=${CNONE}
BG=${BG}
;;
o*)
# occupied desktop
FG=${GREEN}
IC=${CFULL}
BG=${BG}
;;
O*)
# focused occupied desktop
FG="#ac8e8e"
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${BLACK}}%{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
#
# wm independent hotkeys
#
# terminal emulator
super + Return
# urxvt
xfce4-terminal
# program launcher
super + @space
dmenu_run
super + shift + @space
rofi -show run -opacity 90
# make sxhkd reload its configuration files:
super + Escape
pkill -USR1 -x sxhkd
#
# bspwm hotkeys
#
# quit bspwm normally
super + alt + Escape
bspc quit
# close and kill
super + {_,shift + }w
bspc node -{c,k}
# alternate between the tiled and monocle layout
super + m
bspc desktop -l next
# if the current node is automatic, send it to the last manual, otherwise pull the last leaf
super + y
bspc query -N -n focused.automatic && bspc node -n last.!automatic || bspc node last.leaf -n focused
# swap the current node and the biggest node
super + g
bspc node -s biggest
#
# state/flags
#
# set the window state
super + {t,shift + t,s,f}
bspc node -t {tiled,pseudo_tiled,floating,fullscreen}
# set the node flags
super + ctrl + {x,y,z}
bspc node -g {locked,sticky,private}
#
# focus/swap
#
# focus the node in the given direction
super + {_,shift + }{h,j,k,l}
bspc node -{f,s} {west,south,north,east}
# focus the node for the given path jump
super + {p,b,comma,period}
bspc node -f @{parent,brother,first,second}
# focus the next/previous node in the current desktop
super + {_,shift + }c
bspc node -f {next,prev}.local
# focus the next/previous desktop in the current monitor
super + bracket{left,right}
bspc desktop -f {prev,next}.local
# focus the last node/desktop
super + {grave,Tab}
bspc {node,desktop} -f last
# focus the older or newer node in the focus history
super + {o,i}
bspc wm -h off; \
bspc node {older,newer} -f; \
bspc wm -h on
# focus or send to the given desktop
super + {_,shift + }{1-9,0}
bspc {desktop -f,node -d} '^{1-9,10}'
#
# preselect
#
# preselect the direction
super + ctrl + {h,j,k,l}
bspc node -p {west,south,north,east}
# preselect the ratio
super + ctrl + {1-9}
bspc node -o 0.{1-9}
# cancel the preselection for the focused node
super + ctrl + space
bspc node -p cancel
# cancel the preselection for the focused desktop
super + ctrl + shift + space
bspc query -N -d | xargs -I id -n 1 bspc node id -p cancel
#
# move/resize
#
# expand a window by moving one of its side outward
super + alt + {h,j,k,l}
bspc node -z {left -20 0,bottom 0 20,top 0 -20,right 20 0}
# contract a window by moving one of its side inward
super + alt + shift + {h,j,k,l}
bspc node -z {right -20 0,top 0 20,bottom 0 -20,left 20 0}
# move a floating window
super + {Left,Down,Up,Right}
bspc node -v {-20 0,0 20,0 -20,20 0}
#
# wm independent hotkeys
#
# terminal emulator
super + Return
# urxvt
xfce4-terminal
# program launcher
super + @space
dmenu_run
# make sxhkd reload its configuration files:
super + Escape
pkill -USR1 -x sxhkd
#
# bspwm hotkeys
#
# quit bspwm normally
super + alt + Escape
bspc quit
# close and kill
super + {_,shift + }w
bspc node -{c,k}
# alternate between the tiled and monocle layout
super + m
bspc desktop -l next
# if the current node is automatic, send it to the last manual, otherwise pull the last leaf
super + y
bspc query -N -n focused.automatic && bspc node -n last.!automatic || bspc node last.leaf -n focused
# swap the current node and the biggest node
super + g
bspc node -s biggest
#
# state/flags
#
# set the window state
super + {t,shift + t,s,f}
bspc node -t {tiled,pseudo_tiled,floating,fullscreen}
# set the node flags
super + ctrl + {x,y,z}
bspc node -g {locked,sticky,private}
#
# focus/swap
#
# focus the node in the given direction
super + {_,shift + }{h,j,k,l}
bspc node -{f,s} {west,south,north,east}
# focus the node for the given path jump
super + {p,b,comma,period}
bspc node -f @{parent,brother,first,second}
# focus the next/previous node in the current desktop
super + {_,shift + }c
bspc node -f {next,prev}.local
# focus the next/previous desktop in the current monitor
super + bracket{left,right}
bspc desktop -f {prev,next}.local
# focus the last node/desktop
super + {grave,Tab}
bspc {node,desktop} -f last
# focus the older or newer node in the focus history
super + {o,i}
bspc wm -h off; \
bspc node {older,newer} -f; \
bspc wm -h on
# focus or send to the given desktop
super + {_,shift + }{1-9,0}
bspc {desktop -f,node -d} '^{1-9,10}'
#
# preselect
#
# preselect the direction
super + ctrl + {h,j,k,l}
bspc node -p {west,south,north,east}
# preselect the ratio
super + ctrl + {1-9}
bspc node -o 0.{1-9}
# cancel the preselection for the focused node
super + ctrl + space
bspc node -p cancel
# cancel the preselection for the focused desktop
super + ctrl + shift + space
bspc query -N -d | xargs -I id -n 1 bspc node id -p cancel
#
# move/resize
#
# expand a window by moving one of its side outward
super + alt + {h,j,k,l}
bspc node -z {left -20 0,bottom 0 20,top 0 -20,right 20 0}
# contract a window by moving one of its side inward
super + alt + shift + {h,j,k,l}
bspc node -z {right -20 0,top 0 20,bottom 0 -20,left 20 0}
# move a floating window
super + {Left,Down,Up,Right}
bspc node -v {-20 0,0 20,0 -20,20 0}
;=====================================================
;
; To learn more about how to configure Polybar
; go to https://github.com/jaagr/polybar
;
; The README contains alot of information
;
;=====================================================
;=====================================================
; Includes
;=====================================================
[section/base]
include-file = /home/epsi/.config/polybar/main.conf
include-file = /home/epsi/.config/polybar/modules-top.conf
include-file = /home/epsi/.config/polybar/modules-bottom.conf
include-file = /home/epsi/.config/polybar/modules-separator.conf
;=====================================================
; i3 Bars
;=====================================================
[bar/top]
inherit = bar/main
bottom = false
modules-left = bspwm
modules-center = mpd
modules-right = date powermenu
width = 90%
offset-x = 5%
height = 24
radius = 6.0
font-0 = "xos4 Terminus:size=8:antialias=false;2"
font-1 = "takaopgothic:pixelsize=9;1"
font-2 = "Wuncon Siji:pixelsize=10;1"
background = ${colors_top.background}
foreground = ${colors_top.foreground}
line-size = 3
line-color = #f00
border-size = 4
border-color = #00000000
[bar/bottom]
inherit = bar/main
bottom = true
underline-size = 0
overline-size = 0
modules-left = right2 filesystem right1 right2 memory right1 right2 cpu right1
modules-center = right2 volume right1 right2 wlan left2
modules-right = left1 battery left2 left1 temperature left2
width = 100%
height = 19
radius = 0
font-0 = "xos4 Terminus:size=8:antialias=false;4"
font-1 = "PowerlineExtraSymbols:pixelsize=9;4"
font-2 = "Wuncon Siji:pixelsize=17;4"
offset-x = 0
offset-y = 0
fixed-center = true
border-bottom-size = 4
border-bottom-color = ${colors_bottom.background}
border-top-size = 4
border-top-color = ${colors_bottom.background}
background = ${colors_bottom.background}
foreground = ${colors_bottom.foreground}
module-margin = 0
padding-right = 2
padding-left = 2
tray-position = right
tray-padding = 5
tray-background = ${colors_bottom.background}
; vim:ft=dosini