We all love MATE Desktop, and we all know that mate-power-manager does not work correctly. On my box the only thing that worked was setting the screen brightness, for which function I found a replacement:
Install xrandr and use the following script (which does not need root privileges):
Code:
#!/bin/bash
#xev output:
#Brightness down: keycode 232 (keysym 0x1008ff03, XF86MonBrightnessDown)
#Brightness up: keycode 233 (keysym 0x1008ff02, XF86MonBrightnessUp)
if [[ -f "${HOME}/.brightnessrc" ]]; then
LEVEL=`cat ${HOME}/.brightnessrc`
else
LEVEL=1
fi
brightness ()
#the values for the xrandr command are from the output of xrandr --current --verbose; they may be different on different boxes. xrandr does not seem to have any safeguards against incorrect input, hence the tests:
{
if [[ "$LEVEL" =~ [[:digit:]] ]] && [[ "$(echo "$LEVEL <= 1" | bc)" -eq 1 ]] && [[ "$(echo "$LEVEL >= 0.1" | bc)" -eq 1 ]]; then
xrandr --output 0x52 --crtc 0 --brightness "$LEVEL"
echo "$LEVEL" > ${HOME}/.brightnessrc
exit 0
else
exit 1
fi
}
case $1 in
#Set brightness manually:
+)
LEVEL=$(echo "scale=2; $LEVEL + 0.05" | bc)
brightness
;;
-)
LEVEL=$(echo "scale=2; $LEVEL - 0.05" | bc)
brightness
;;
#For a startup object to set brightness:
*)
brightness
;;
esac
Save the script as /usr/local/bin/brightness or $HOME/brightness.
On the Apple keyboard the brightness keys (F1 and F2, XF86MonBrightnessDown and XF86MonBrightnessUp) can be assigned to the commands "brightness -" and "brightness +".
*****
How to implement automatic shutdown after an hour of inactivity:
Install xautolock and use the following .xinitrc:
Code:
#!/bin/sh
#
# ~/.xinitrc
#
# Executed by startx (run your window manager from here)
if [ -d /etc/X11/xinit/xinitrc.d ]; then
for f in /etc/X11/xinit/xinitrc.d/*; do
[ -x "$f" ] && . "$f"
done
unset f
fi
xautolock -time 60 -locker "/usr/bin/systemctl suspend" &
# exec gnome-session
# exec startkde
# exec startxfce4
# ...or the Window Manager of your choice
exec mate-session
This is for Archlinux but should also work for other distros, with the appropriate locker command.