#[SOLVED] Starting DPMS manually and waking display up on activity

65 messages · Page 1 of 1 (latest)

finite holly
#

Is there a way I can start dpms manually on arch and wake up the display again on any activity, like randomly moving a mouse or pressing any key on keyboard?

I am running sway wm and i am already using swayidle which triggers dpms after 10 minutes of inactivity. That works perfectly, which means when swayidle triggers the dpms i can wake up my monitor again by moving mouse or pressing something on keyboard.

But if i try to manually run the command swaymsg output * power off that does the trick of turning dpms off but i can't turn my monitors on again unless i do swaymsg output * dpms on which is a bit tricky since the monitors are off and i see nothing.

I can't run swayidle twice.

Thank you very much in advance.

near hull
#

what about swaymsg output * dpms off ?

finite holly
#

that command does work, but i cant wake up the pc again unless i type swaymsg output * dpms on. And as i said its difficult and dumb trying to type that command if i see nothing (monitor is turned off). And besides that i want to wake up turned off monitor just by some activity like moving a mouse or pressing any key on a keyboard and not such a long command

near hull
#

So that command has the same behaviour as swaymsg output * power off ?

finite holly
#

Yes they are the same commands, swaymsg output * dpms off is just the deprecated version. But as is said completely same commands.

thorny junco
#

u could try make ur own script and systemd unit to have it always running in the background on startup that just detects any activity and auto runs saymsg output * power on for u when it detects the activity

near hull
#

I've hacked at this a bit (I use niri) and this would work for keypresses, at least

swayidle -w timeout 1 "niri msg action power-off-monitors" & read -q; kill $! 
#

It waits for read (any keypress) and kills $! which is the most recent subcommand (the swayidle one)

thorny junco
#

libinput debug-events ran as root outputs a line whenever there's input from anything including mouse or keyboard

#

i think u can add urself to the input group then u dont need root

#

so if u had a script just checking if that ever outputs anythin and then if monitors are off turn them on

finite holly
finite holly
near hull
#

They don't appear to conflict

thorny junco
finite holly
near hull
#

Oh yeah, read -q is a zshism

finite holly
near hull
#

The -q on the read is just to make it return on any keypress, if you're in sh or bash then I think read -n1 would have a similar effect

finite holly
#

@near hull do u have an already running instance of swayidle? just to make clear

near hull
#

I do, yeah

#

5 min timeout

#

Tbh I dunno why swayidle works for you but the manual command doesn't respond to mouse movement or keypress

finite holly
#

and with that command after sleeping it wakes up on any activity?

near hull
#

Any keypress, read ignores the mouse

#

It's 150% a hack 😄

finite holly
#

swayidle -w timeout 1 'swaymsg "output * dpms off"' resume 'swaymsg "output * dpms on"' can u try this

near hull
#
swayidle -w timeout 1 "swaymsg output * dpms off" & read -q; kill $!; swaymsg output * dpms on
``` would probably be better, explicitly turn the monitors back on on exit
finite holly
# near hull 5 min timeout

i was thinking about this. when dpms triggers after 5 mins does monitor start on any keypress? since here u have no read command

near hull
#

The niri-ran swayidle works normally, niri will turn the monitors on again itself with any activity

thorny junco
# near hull 5 min timeout

cuz its swayidle detecting when there's acitivty and then running the resume command given to it, right?

near hull
#

It should run the resume command on activity, yeah. I guess niri doesn't require that

#
swayidle -w timeout 1 "swaymsg output * dpms off" resume 'swaymsg output * dpms on' & read -n1; kill $!
``` I think, then. This will start a new swayidle to blank the screens, turn them on again on activity, and kill that swayidle instance
finite holly
near hull
thorny junco
thorny junco
#

turn monitors off, wait for read to stop blocking and then turn them on when it does

near hull
finite holly
#

its strange for me he can even run two instances of swayidle simultanously

near hull
#

I can't test directly

finite holly
#

i cant

thorny junco
#
echo "power off"
sleep 0.5
libinput debug-events | while read -r line; do
    if [[ ! "$line" =~ DEVICE_ADDED ]]; then
        break
    fi
done
echo "power on"

this script would work, just replace the power off and power on with ur actual sleep/resume commands

#

i just used echo cuz i dont use sway so i just echo to check

#

it says power off and as soon as i touch the mouse it says power on

near hull
#

Fancy pants!

#

That libinput command is slick

finite holly
#

ok that looks fancy

#

still i dont understand how can you run two instances of swayidle while i cant

#

and why does swaylidle listen to activity only when dpms off was ran by swayidle itself

finite holly
#

no nothing

#

Ok i found a problem

#

I put timeout 0 yesterday

thorny junco
finite holly
#

What just happened is that after doing this command swayidle -w timeout 1 'swaymsg "output * dpms off"' resume 'swaymsg "output * dpms on"' my screens turned on and off every second

finite holly
#

I did some more research and tried some more things and the conclusion is that it is probably a bug

#

killall -SIGUSR1 swayidle doesnt work

#

sleep 1; killall -SIGUSR1 swayidle works but i can do that only once or twice after that it doesnt work

#

@thorny junco @near hull thank you very much for your help. i assume this bug will soon be fixed, i will mark this as solved

peak pierBOT
#

yobson, and mushroom.botherer received a thank you cookie!