Forum › Forums › Official Releases › antiX-21/22 “Grup Yorum” › How to programme key to turn off display
Tagged: battery life, blank screen, programme keys
- This topic has 8 replies, 4 voices, and was last updated Aug 20-11:58 am by 3guesses.
-
AuthorPosts
-
August 13, 2022 at 12:15 pm #87160Member
3guesses
Hi,
I often use my laptop unplugged and can currently get almost 10 hours of light use out of it through various means, but to improve this even more I would like to be able to force the screen to blank (it’s currently set at 2 minutes) by pressing one of the function keys. So my questions are:
– can I force the screen to blank (maybe via acpitool?)
– can I programme a function key to execute a command?Thanks for any help!
3g
August 13, 2022 at 12:25 pm #87162Member
blur13
August 13, 2022 at 1:03 pm #87164MemberPPC
::I’ve not paid as much attention to the forum for the last couple of months, but this is a very nice tip to save power specially on laptops, thanks for that blur13!
@3guesses – I’m not aware of how used you are to Linux, or antiX, but I assume you’re not a complete newbie, since you talked about acpitool. Putting blur’s answer in a more practical way:
You can run the command:
xset dpms force offto force the screen to be turned off.
You can test that command on the terminal:
xset dpms force off &The screen will turn on we you press a key (I tested that)
To add this command to a Function key (or any shortcut keys]:
antiX menu > Control Centre > Edit [your Window Manager name: IceWM/Fluxbox/JWM]… > “Keys” Tab > Add the above command to a the desired shortcut key(s) and save [you may need to restart your window manager to make sure the changes are enforced].Example: if you are using the default IceWM Window Manager, to make F12 turn off your screen, you need to add, to the relevant “keys” file a line like (I have not tested this, I don’t use IceWM, but it should work- if it does not, try adding the & at the end of the command):
key "F12" xset dpms force offSave the “keys” file and try it out (if the key fails to work, try restarting your Window Manager).
P.
- This reply was modified 8 months, 4 weeks ago by PPC.
August 15, 2022 at 12:44 pm #87279Member3guesses
::Thanks very much @blur13, @PPC.
I’ve had a look at ~/.icewm/keys but I have one more problem: I’m not entirely sure what the key combination is!
Basically on my laptop there is an icon over the F10 key which seems to indicate switch displays (external / internal) which I would like to use (as I don’t have an external display), but I don’t know what the key combination should be in the keys file. This functionality is achieved by pressing Fn+F10 on my laptop, and I assume it would be one of the XF86… multimedia keys, but it seems to be the only one not listed in the standard keys file.
BTW https://ice-wm.org/man/icewm-keys.html states that you can reload the key assignments by executing:
icesh keysCheers,
3g
EDIT: The key assignment is specified using the #switchkey “Super+p” line! So all sorted – thanks again for your help 😎
- This reply was modified 8 months, 3 weeks ago by 3guesses.
August 17, 2022 at 8:57 am #87373Member
blur13
::XF86Display is probably what you are looking for, if you want to use key XF86*. I’m not familiar with switchkey but if it works, it works. A useful command for finding what different keys are called is xev.
August 17, 2022 at 9:19 am #87375Member
blur13
::Experimented some more with this. At least on my system the keyrelease event immediately triggers the screen to turn on again, so there needs to be a sleep command before. Icewm keys doesnt handle && so I created a simple script:
#!/bin/sh
sleep 1 && xset dpms force offPlace that in $PATH and use, eg.
key “Super+F7” turnoffscreen.sh
This works for me, maybe it will help someone else.
- This reply was modified 8 months, 3 weeks ago by blur13.
August 18, 2022 at 9:49 am #87419Member
seriousness
::In ~/.icewm/keys, I simply map this command to a shortcut:
bash -c 'sleep 1; xset dpms force off'August 18, 2022 at 12:30 pm #87421Member
blur13
August 20, 2022 at 11:58 am #87482Member3guesses
::Experimented some more with this. At least on my system the keyrelease event immediately triggers the screen to turn on again, so there needs to be a sleep command before. Icewm keys doesnt handle && so I created a simple script:
#!/bin/sh
sleep 1 && xset dpms force offPlace that in $PATH and use, eg.
key “Super+F7” turnoffscreen.sh
This works for me, maybe it will help someone else.
I don’t tend to experience that problem using switchkey “Super+p” xset dpms force off in ~/.icewm/keys – very occasionally the screen does blank and then come straight back on again when I press F10, but then I just press F10 again 😎
- This reply was modified 8 months, 3 weeks ago by 3guesses.
-
AuthorPosts
- You must be logged in to reply to this topic.