Since a couple of days a very old Chromium bug irritates me. Numerous topics about this in all possible forums, Reddit, Ubuntu, Mint, Brave, XFCE, etc…since at least 2018. In theory it was fixed but it seems not completely.
Particularly, sometimes after i watch video in the browser but later close the tab or the browser, the power inhibition stays and the laptop does not go to sleep.
Example of topics discussing it:
So here is a script that checks every minute if the browser is not running anymore but the inhibition lock is left hanging behind - and then restarts the power manager if needed (on XFCE), cleaning the inhibitor.
power-inhibitor-fix
#!/bin/bash
# The script is for XFCE and checks every 55 seconds
# if Chromium is NOT running BUT has a leftover power-inhibition
# and restarts the power manager clearing the leftover and allowing sleep.
# needed dependency: wmctrl
while true
do
if [[ $(dbus-send --print-reply=literal --dest=org.freedesktop.PowerManagement /org/freedesktop/PowerManagement/Inhibit org.freedesktop.PowerManagement.Inhibit.GetInhibitors |grep chromium) ]]; then
if ! [[ $(wmctrl -l |grep Chromium) ]]; then
xfce4-power-manager --restart
fi
fi
sleep 55
done