How do I stop screen dim/screen energy/sleep mode while watching youtube?

But isn’t there some kind of sys-whatever to make that dbus signal go through it or something like that? After all it’s the VM that keep the signal alive and all is needed is to intercept that signal and I don’t know, transfer/inform dom0 about it somehow?
Or am I not getting it?

for security reasons you don’t want to connect dom0 dbus with another dbus :frowning:

Yes, you can. If you do not have sys-audio qube (99% you do not, it still not fully supported), you can run in dom0 a simple script, that will prevent xscreensaver and other power management from activating when you have sound in pulseaudio.
This way when you watch video, it will never lock nor sleep. But when you stop or pause, it will, in the usual time you set in the screensaver settings (e.g. in 15 minutes).

2 Likes

do you have such script at hand?

1 Like

Yeah, I don’t have sys-audio(yet?), is there a guide/script/or maybe someone can come up with this please?

This script will scan the window title for YouTube and turn on/off presentation mode, you can cron run it every 5 min in dom0.

#!/bin/bash

if xdotool search --name YouTube; then
	xfconf-query -c xfce4-power-manager -p /xfce4-power-manager/presentation-mode -s false
else
	xfconf-query -c xfce4-power-manager -p /xfce4-power-manager/presentation-mode -s true
fi
2 Likes

Yeah, thanks for that link, I’m gonna setup it in upcoming days, but I meant guide/script for what balko said

@renehoj Thanks! But this approach isn’t going to do much as it will not toggle the presentation mode when that window is present, but say a video finished, you know? balko’s way is more like a traditional approach… this way when the video is going it will keep the screen on and if the video stopped it will kick the suspend/sleep/whatever… but I have no idea how to do it, google doesn’t help much either

I used something like that. The script was made a long time ago, so its style looks as a mix of bash and sh, but the point should be clear.

This script being added to autostart (not cron, just run once) should prevent screen blank and screensaver activation when any media is played, does not matter youtube, smplayer, mpv or some web page in browser.

#!/bin/bash

shopt -s dotglob
export LC_ALL=en_US.utf8

sleep 30

while true; do

    active_sink_inputs=`pacmd list-sink-inputs | grep -c "state: RUNNING"`
    screensaved_active=`xscreensaver-command --time | grep -c -E ' (locked|blanked)'`
    
    date_prefix=`date '+%Y-%m-%d_%H-%M-%S'`
    
    dpms_status=`xset -q | grep -c 'DPMS is Enabled'`

    if [ X"$screensaved_active" != X"0" ]; then
        echo "$date_prefix: Screensaver is active (locked or blanked). Doing nothing"
        #xset +dpms        
    elif [ X"$active_sink_inputs" != X"0" ]; then    
        echo "$date_prefix: Running sink-input found. Blocking screensaver timer dpms"
        if [ X"$dpms_status" = X"1" ]; then
            # deactivate and reactive again
            xset -dpms && xset dpms
        fi
        xscreensaver-command -deactivate > /dev/null
    else
        echo "$date_prefix: No running sink-inputs found. Doing nothing"        
        #xset +dpms
    fi

    sleep 50
    
done

P.S. I hope something like that will be available out of box in Qubes OS someday, as it is so small and easy.

3 Likes

Thank you so much! I actually went hardcore with what Tezeria said and installed that audio-qube… it kinda works… I don’t know if there will be issues with this as you said it’s not fully supported? But the more important question is what should I tweak in that script so it will work with my sys-audio? or is it completely different now?

Why? That was not a great idea if you do not need bluetooth audio output.
I said about not having sys-audio just because my solution will not work if you have one. Not like it is good to have it if you do not need it.

You should either revert the sys-audio qube actions (possible, nothing drastic happened) to make my solution work, because it runs in dom0, check pulseaudio in dom0 and prevents xscreensaver from running in dom0.
Or you have to complicate things further and run like 2 scripts, one in sys-audio with pulseaudio checks and another in dom0 that would ask the first script (check e.g. some lock file in sys-audio) and prevent xscreensaver or something from starting.

1 Like

Nah, I’ll go back to what it was :smiley:
I shouldn’t do anything to make it work with KDE, right? you also use KDE?

What do you mean exactly?
I use KDE apps in qubes (because they are by far superior to Gnome/GTK), but not in dom0 (the official support of KDE in dom0 unfotunately was dropped).

Anyway, the solution does not depend on XFCE/KDE in dom0 anyway.
But note that I made and used this script on Qubes OS ~4.0 and not sure if it still works as is.

Em… I followed the docs in KDE (desktop environment) | Qubes OS and just installed it as it says in dom0…

At some point there was a choice during installation - KDE or XFCE. But nowadays, it’s only XFCE.

That’s the default DE you’re talking about.
KDE is officially supported as far as the docs say: KDE (desktop environment) | Qubes OS

More over, there’s a tendency by Qubes to support KDE 6 and to move towards wayland as x11 will be dropped by Fedora.

No, I am talking about support of the KDE. I like KDE way more than XFCE or other GTK/Gnome ugliness.
Of cause user can install in dom0 any DE, it’s Fedora atfer all, but it will not make Qubes OS support all possible DEs. The tendency with KDE in Qubes OS is quite clear: KDE is not supported, not tested enough by devs (because almost nobody uses it among them?). Also, when KDE was an option during installation (not even default one), it was supported, because more more casual users were able to chose it during installation.

Nowadays, unfortunately, KDE in Qubes OS is not expected to work even as “fine” as XFCE, which itself is full of bugs and is lacking basic features like proper windows placement. Hopefully inevitable migration to wayland will force Qubes OS to move back to functional and advanced DE, because XFCE is half-dead and not actively developed. But currently we are not there yet.

But this all is off-topic.

I think XFCE people are working on it to make wayland compatible.

That would be unfortunate and would prolong xfce-era of Qubes OS with ugly look that scares away casual Linux users and lack of basic DE features that annoys advanced users.

1 Like

Why not list these bugs in the corresponding thread then, perhaps, so we could discuss it and maybe help you out
https://forum.qubes-os.org/t/kde-changing-the-way-you-use-qubes/