Last active
February 11, 2023 00:44
-
-
Save pedrominicz/fb9f3e94d2acb9aba6f28fffd9867137 to your computer and use it in GitHub Desktop.
Minimal xinitrc for dwm
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# Source global X session scripts. | |
if [ -d /etc/X11/xinit/xinitrc.d ]; then | |
for f in /etc/X11/xinit/xinitrc.d/*; do | |
[ -x "$f" ] && . "$f" | |
done | |
unset f | |
fi | |
xmodmap -e 'clear Lock' -e 'keycode 0x42 = Escape' -e 'keycode 0x86 = Multi_key' | |
redshift -PO 3000 | |
feh --no-fehbg --bg-fill "$HOME/etc/.bg.png" | |
export GTK_IM_MODULE='fcitx' | |
export QT_IM_MODULE='fcitx' | |
export XMODIFIERS='@im=fcitx' | |
# Uncheck "Allow Overriding System XKB Settings" on Fcitx's XCB add-on settings | |
# to prevent it from undoing the `xmodmap` above. | |
fcitx5 & | |
battery() { | |
battery='/sys/class/power_supply/BAT0' | |
if [ -d "$battery" ]; then | |
echo -n ' | ' | |
if grep -q 'Charging' "$battery/status"; then | |
echo -n '+' | |
fi | |
tr -d '\n' <"$battery/capacity" | |
echo '%' | |
fi | |
} | |
while true; do | |
xprop -root -set WM_NAME "$(date '+%A, %B %-d, %-I:%M %p')$(battery)" | |
sleep 15 | |
done & | |
st & | |
anki & | |
exec dwm |
@pranavgade20, you are absolutely right! This script was pretty bad. I'll leave an improved version close to the original here, because I am about to change it a bit.
#!/bin/sh
# Source global X session scripts.
if [ -d /etc/X11/xinit/xinitrc.d ]; then
for f in /etc/X11/xinit/xinitrc.d/*; do
[ -x "$f" ] && . "$f"
done
unset f
fi
feh --bg-fill "$HOME/pictures/wallpaper.png"
xmodmap -e 'clear Lock' -e 'keycode 0x42 = Escape'
redshift -PO 3000
day() {
day="$(date '+%-d')"
case "$day" in
1|21|31) echo "${day}st";;
2|22) echo "${day}nd";;
3|23) echo "${day}rd";;
*) echo "${day}th";;
esac
}
battery() {
battery='/sys/class/power_supply/BAT0'
if [ -d "$battery" ]; then
echo ' | '
if grep -q 'Charging' "$battery/status"; then
echo '+'
fi
cat "$battery/capacity"
echo '%'
fi
}
while true; do
xprop -root -set WM_NAME "$(date "+%A, %B $(day) %-H:%M")$(battery)"
sleep 15
done &
st &
exec dwm
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You might want to change the 1 in line 26 to 01, as
date +%d
outputs 01 on the first of every month (same for lines 27 and 28 as well)