You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
# Set keyboard layout
|
|
|
|
setxkbmap \
|
|
|
|
-option 'grp:alt_shift_toggle' \
|
|
|
|
-option 'caps:swapescape' \
|
|
|
|
'dvorak,ru'
|
|
|
|
|
|
|
|
# Battery
|
|
|
|
BATTERY="BAT0"
|
|
|
|
HAS_BATTERY="no"
|
|
|
|
LOW_BATTERY_LIMIT=20
|
|
|
|
if [ -d /sys/class/power_supply/$BATTERY ]; then
|
|
|
|
HAS_BATTERY="yes"
|
|
|
|
fi
|
|
|
|
|
|
|
|
battery_is_charging() {
|
|
|
|
battery_status=$(cat /sys/class/power_supply/$BATTERY/status)
|
|
|
|
|
|
|
|
if [ $battery_status = "Charging" ]; then
|
|
|
|
return 0;
|
|
|
|
fi
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
battery_level() {
|
|
|
|
echo $(cat /sys/class/power_supply/$BATTERY/capacity)
|
|
|
|
}
|
|
|
|
|
|
|
|
battery_level_too_low() {
|
|
|
|
if [ $(eval battery_level) -lt $LOW_BATTERY_LIMIT ]; then
|
|
|
|
return 0;
|
|
|
|
fi
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
while true; do
|
|
|
|
XROOTNAME="RAM: $(free -m | grep '^Mem' | awk '{print $3"MB"}') |"
|
|
|
|
XROOTNAME="$XROOTNAME CPU: $(top -bn1 | awk '/Cpu/ { print $2}')% |"
|
|
|
|
if [ $HAS_BATTERY = "yes" ]; then
|
|
|
|
XROOTNAME="$XROOTNAME BAT: $(eval battery_level)%"
|
|
|
|
if battery_level_too_low; then
|
|
|
|
XROOTNAME="$XROOTNAME PLUG CHARGER"
|
|
|
|
fi
|
|
|
|
XROOTNAME="$XROOTNAME |"
|
|
|
|
fi
|
|
|
|
XROOTNAME="$XROOTNAME $(date +"%F %R")"
|
|
|
|
|
|
|
|
xsetroot -name "$XROOTNAME"
|
|
|
|
sleep 20s
|
|
|
|
done &
|
|
|
|
|
|
|
|
# Set wallpaper
|
|
|
|
xsetroot -solid gray
|
|
|
|
feh --bg-scale ./.fehbg/wallpaper.png
|
|
|
|
|
|
|
|
# Start window manager
|
|
|
|
exec dwm
|