Command Shortcut to turn off screen

Hello,

As the title says is there a keyboard shortcut I can create to turn off laptop screen but keep sound on and not locking the session?
I already made a command keyboard shortcut that turns off screen But also cut off sound and locks session.

I would like to create this shortcut to only turn off screen but would like to listen to music with screen off.

Thanks

Hi. I think you can just set screen brightness to 0 with an utility such as light. Install light package and then create a shortcut for this command:
light -S 0
Make sure you can increase the screen brightness later.

I actually found the command works:

xset dpms force off

However I would like to assign it to one press on the power button.
Is there a way to do this?

1 Like

Since you are on Xfce: go to xfce4-keyboard-settings, then on the Application Shortcuts tab: there you can assign a shortcut.

1 Like

If you don’t release the key(s) quickly enough the screen might turn back on. So you may want to use this instead.

sleep 1; xset dpms force off

Could you not simply make a script for this; or, rather, for @dmt’s version of the command, and launch it via an alias from your desktop? If you really must have a keyboard shortcut, then just ignore this and happy hunting. :wink:

xset dpms force off is nice - but you can’t afford to touch anything, or it would wake up instantly.

I would suggest you set it to Ctrl_Power or Alt_Power… or change Power to do only the screen and change Alt_power to sleep or whatever.

That does not work at all.

Then presumably xfce only runs the first command.

You could put it in a script.

sleep 5 && xset dpms force off

Try that, to verify the commands work.