I have used Automatically locking screen without shutting it off and other threads but ultimately it locks the screen, which is not what i am asking.
-
1Why are you posting a new question from a new account? Please edit your older question and add details.– pomskyJan 18, 2019 at 8:16
-
sorry about that. but i can't seems to access that a/c. I tried like for an hour and i gave up. Please help me solve the question– PranavJan 18, 2019 at 8:18
-
Through my original a/c, i can't ask question anymore. So i have almost created like 3 a/c to get my answer. Keeping track of them is a bit annoying.– PranavJan 18, 2019 at 8:20
-
u asked me, "gsettings get org.gnome.settings-daemon.plugins.power power-button-action" the output is "suspend".– PranavJan 18, 2019 at 8:21
-
2Please don't demand for an answer in that way. In case you're mistaken Ask Ubuntu is not a free Ubuntu tech support, we're just a community of (mostly) average Ubuntu users. And also I failed to realise how I'm putting you in loop again and again. I suggested something, which didn't work. So I suggested the way to undo the effect of my previous suggestion before completely disengaging from this question. Thank you, have a good day.– pomskyJan 18, 2019 at 9:05
3 Answers
Workaround:
It is possible, if the Menu key could be sacrificed.
First set a custom shortcut for Menu key as xset dpms force off
This means, when you press Menu key, xset dpms force off
command will run and turn off the display.
Now the trick is to map this Menu key to PowerOff key with xmodmap
run xmodmap -pk | grep PowerOff
to know the keycode for PowerOff button.
Example:
pratap@i7-6550U:~$ xmodmap -pk | grep PowerOff
124 0x1008ff2a (XF86PowerOff) 0x0000 (NoSymbol) 0x1008ff2a (XF86PowerOff) 0x0000 (NoSymbol) 0x1008ff2a (XF86PowerOff)
pratap@i7-6550U:~$
In my case 124 is the Key code for PowerOff Button with my Keyboard.
now run the below command in terminal to map the PowerOff key to Menu key.
xmodmap -e "keycode 124 = Menu"
at this stage you literally have two Menu Keys in your keyboard which will run the command xset dpms force off
.
Now you can check, if you press Menu Key or PowerOff key the display will be turned off.
the command xmodmap -e "keycode 124 = Menu"
will not survive logout or reboot.
So, Create a startup preferences with command xmodmap -e "keycode 124 = Menu"
like below and then Reboot.
When ever you want to remove this mapping, just delete the entry from startup preferences.
-
That seems very promising and real but when i at the time of choosing a Keyboard, "Power button" doesn't respond at all. That is, it ain't get selected or anything like that.– PranavJan 19, 2019 at 3:24
-
Can u explain it in minor details? "snap left ?" (I do have dconf edit though).– PranavJan 19, 2019 at 4:27
-
-
Power button did "split on right". After that i managed to edit put "Power button" on custom shortkey which was designed to "turn off the screen". After that i use above ( gsettings set org.gnome.settings-daemon.plugins.power button-power 'nothing' && gsettings set org.gnome.settings-daemon.plugins.power power-button-action 'nothing' ). Now even when everything alright, power button do nothing.– PranavJan 19, 2019 at 6:30
-
1I Didn't use Menu button as after looking through the keymap, I found some keys for Japanese keyboard that I would imagine most of us have never used. For example, I rebinded the power button to 'Katakana' and it worked perfectly, without sacrificing any functionalities.– KeniviaDec 25, 2019 at 11:56
You can set the power management to turn off the screen when you press the power button, but unless automatic locking is set to "Off" (in "Privacy" setting), the system will lock when you turn off the screen.
Unfortunately there's no way in Ubuntu (based on GNOME) to change that behavior - either no lock at all, or lock when the screen turns off.
Other desktop environment, such as KDE Plasma, XFCE or Budgie might offer more refined settings.
This is really simple
first go to settings > power >and set the power button to do nothing
next go to settings > keyboard > shortcuts > custom
add the custom command xset dpms force off and set its accelerator as power+cntr
hope this helped
i tried this in elementry os hera but scince elementry is based on ubuntu it should work just as well