05-30-2021, 10:35 PM
Hi, dont know for i3, on sway i did :
1/ inhibit powerbutton in systemd/logind.conf
HandlePowerKey=ignore
2/ sway/config
# power button
bindsym XF86PowerOff exec ~/bin/wayland_toggle_screen.sh
3/ with wayland_toggle_screen.sh :
#!/bin/sh
read lcd < /tmp/lcd
if [ "$lcd" -eq "0" ]; then
swaymsg "output * dpms on"
echo 1 > /tmp/lcd
else
swaymsg "output * dpms off"
echo 0 > /tmp/lcd
fi
it works nice (powerbutton does switch screen on/off)
1/ inhibit powerbutton in systemd/logind.conf
HandlePowerKey=ignore
2/ sway/config
# power button
bindsym XF86PowerOff exec ~/bin/wayland_toggle_screen.sh
3/ with wayland_toggle_screen.sh :
#!/bin/sh
read lcd < /tmp/lcd
if [ "$lcd" -eq "0" ]; then
swaymsg "output * dpms on"
echo 1 > /tmp/lcd
else
swaymsg "output * dpms off"
echo 0 > /tmp/lcd
fi
it works nice (powerbutton does switch screen on/off)