Skip to content

Instantly share code, notes, and snippets.

@skylerspaeth
Last active August 25, 2020 01:57
Show Gist options
  • Save skylerspaeth/0caf69b6f27d2fae05aaea6522fe2143 to your computer and use it in GitHub Desktop.
Save skylerspaeth/0caf69b6f27d2fae05aaea6522fe2143 to your computer and use it in GitHub Desktop.
.xinitrc to start dwm with custom status bar and tryone's compton fork
#!/bin/sh
userresources=$HOME/.Xresources
usermodmap=$HOME/.Xmodmap
sysresources=/etc/X11/xinit/.Xresources
sysmodmap=/etc/X11/xinit/.Xmodmap
# merge in defaults and keymaps
if [ -f $sysresources ]; then
xrdb -merge $sysresources
fi
if [ -f $sysmodmap ]; then
xmodmap $sysmodmap
fi
if [ -f "$userresources" ]; then
xrdb -merge "$userresources"
fi
if [ -f "$usermodmap" ]; then
xmodmap "$usermodmap"
fi
# start some nice programs
if [ -d /etc/X11/xinit/xinitrc.d ] ; then
for f in /etc/X11/xinit/xinitrc.d/?*.sh ; do
[ -x "$f" ] && . "$f"
done
unset f
fi
#twm &
#xclock -geometry 50x50-1+1 &
#xterm -geometry 80x50+494+51 &
#xterm -geometry 80x20+494-0 &
#exec xterm -geometry 80x66+0+0 -name login
# keyboard layout
#setxkbmap en &
batt(){
battSte=$(cat /sys/devices/platform/smapi/BAT0/state)
battPct=$(cat /sys/devices/platform/smapi/BAT0/remaining_percent)
battEmr=$(cat /sys/devices/platform/smapi/BAT0/remaining_running_time)
# conditionals to check charging status
if [[ "$battSte" == "discharging" ]]; then
battEmo="🔻"
elif [[ "$battSte" == "idle" ]]; then
battEmo="✅"
elif [[ "$battSte" == "charging" ]]; then
battEmo="🔺"
else
battEmo="Unknown state: $battSte"
fi
# conditionals to check time remaining
if [[ "$battEmr" == "not_discharging" ]]; then
battTme="$(cat /sys/devices/platform/smapi/BAT0/remaining_charging_time)ECMR"
elif [[ "$battEmr" == "not_charging" ]]; then
battTme=""
else
battTme="$(echo $battEmr)EMR"
fi
# concatenate
echo "$battTme $battEmo$battPct%"
}
# dispaly res
# xrandr --output Virtual-1 --mode 1920x1080 &
# compositor
nitrogen --restore &
compton --config /home/skylerspaeth/.config/compton/compton.conf &
# status bar
newpkgs=$(checkupdates | wc -l)
while true; do
xsetroot -name "🔧$newpkgs | 🔋$(batt) | $(date '+%m:%d:%y %H:%M:%S')"
sleep 1s
done &
# execute dwm
exec dwm
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment