Getting special keys to work [COMPLETELY SOLVED]
John Hupp
lubuntu at prpcompany.com
Tue May 6 22:19:18 UTC 2014
It turns out that com.ubuntu.enable-hibernate.pkla needs another
stanza. Make it thus:
[Re-enable hibernate by default in upower]
Identity=unix-user:*
Action=org.freedesktop.upower.hibernate
ResultActive=yes
[Re-enable hibernate by default in logind]
Identity=unix-user:*
Action=org.freedesktop.login1.hibernate
ResultActive=yes
Now both Menu: Hibernate and the dbus-send command will work:
dbus-send --print-reply --system --dest=org.freedesktop.UPower
/org/freedesktop/UPower org.freedesktop.UPower.Hibernate
See
http://ubuntuhandbook.org/index.php/2014/04/enable-hibernate-ubuntu-14-04/
On 4/30/2014 7:50 PM, John Hupp wrote:
> Re: Getting special keys to work [MOSTLY SOLVED]
> See http://ubuntuforums.org/showthread.php?t=813387&page=6 #57 for
> dbus-send commands that accomplish most of what I wanted.
>
> Restart:
> dbus-send --system --print-reply --dest=org.freedesktop.ConsoleKit
> /org/freedesktop/ConsoleKit/Manager
> org.freedesktop.ConsoleKit.Manager.Restart
>
> Shutdown:
> dbus-send --system --print-reply --dest=org.freedesktop.ConsoleKit
> /org/freedesktop/ConsoleKit/Manager
> org.freedesktop.ConsoleKit.Manager.Stop
>
> Suspend:
> dbus-send --print-reply --system --dest=org.freedesktop.UPower
> /org/freedesktop/UPower org.freedesktop.UPower.Suspend
>
> Hibernate does not work, but it turns out that it does not work in the
> Lubuntu logout menu either. See bug
> https://bugs.launchpad.net/ubuntu/+source/lxsession/+bug/1300798. But
> if "sudo pm-hibernate" works, then you can also make Hibernate work
> from the logout menu in accord with the given workaround:
> Create the file
> /etc/polkit-1/localauthority/50-local.d/com.ubuntu.enable-hibernate.pkla
>
> The file must have the following content:
>
> [Re-enable hibernate by default]
> Identity=unix-user:*
> Action=org.freedesktop.login1.hibernate
> ResultActive=yes
>
> There is also a dbus-send command which would be nice for a keyboard
> shortcut, but even after creating the above file it yields a "not
> authorized" error for reasons I don't understand. The dbus-send command:
> dbus-send --print-reply --system --dest=org.freedesktop.UPower
> /org/freedesktop/UPower org.freedesktop.UPower.Hibernate
>
> On 4/30/2014 4:11 PM, John Hupp wrote:
>> One problem solved: If I use "nmcli nm wifi on" and "nmcli nm wifi
>> off" instead of the rfkill commands, this toggles the wifi radio
>> without root permissions.
>>
>> Now if I could find some suspend/standby and hibernate commands that
>> don't require root permission, this job would be done!
>>
>> On 4/30/2014 3:30 PM, John Hupp wrote:
>>> I spoke too soon. All the programs (rfkill, pm-suspend,
>>> pm-hibernate) must run as root, and nothing I have tried so far has
>>> allowed these keys to work as I intend.
>>>
>>> I created /home/<user>/.config/openbox/toggle-wifi.sh with this content:
>>>
>>> #!/bin/bash
>>>
>>> if [ $(rfkill list wifi | grep "Soft blocked: yes" | wc -l) -eq 1 ]
>>> ; then
>>> rfkill unblock wifi
>>> zenity --info --text "Enabled wireless"
>>> else
>>> rfkill block wifi
>>> zenity --info --text "Disabled wireless"
>>> fi
>>>
>>> On 4/30/2014 1:09 PM, John Hupp wrote:
>>>> After thinking about it, I used an Upstart job to do what the
>>>> MultiMediaKeys article instructed to be done with bootmisc.sh or
>>>> rc.local.
>>>>
>>>> Though I'm no better than an Upstart hacker, especially with regard
>>>> to choice of a 'start on' event, I created
>>>> /etc/init/kb-keys-customize.conf with this content:
>>>>
>>>> # kb-keys-customize
>>>> # Map key codes to the scan codes emitted by Fn-F4, Fn-F5, Fn-F12
>>>>
>>>> description "Map Fn-F4, Fn-F5 and Fn-F12 kernel scancodes to kernel
>>>> keycodes"
>>>> author "John Hupp"
>>>>
>>>> start on local-filesystems
>>>>
>>>> script
>>>> setkeycodes e017 128 e016 129 e018 130
>>>> end script
>>>>
>>>> After rebooting, I found that 'xev -event keyboard' now reports
>>>> that Fn-F4, Fn-F5 and Fn-F12 are mapped to X keysyms Cancel, Redo
>>>> and SunProps, so I expect that I should be able to bind those keys
>>>> in lubuntu-rc.xml to Andre's suggested commands.
>>>>
>>>> On 4/29/2014 6:08 PM, John Hupp wrote:
>>>>> The next problem is that Fn-F4 and Fn-F5 don't generate any
>>>>> keysyms, so they can't be bound to the commands suggested by Andre.
>>>>>
>>>>> To deal with that, I've been following the In-Depth Instructions
>>>>> in https://help.ubuntu.com/community/MultimediaKeys, and I have
>>>>> identified the scancodes and picked a couple unassigned kernel
>>>>> keycodes, but that article is old, and writing setkeycodes
>>>>> commands into /etc/init.d/bootmisc.sh or /etc/rc.local seems
>>>>> deprecated (those files don't exist).
>>>>>
>>>>> On 4/29/2014 3:54 PM, John Hupp wrote:
>>>>>> I've been looking at the Exec lines in several versions of
>>>>>> ~/.config/autostart/LXRandR-autostart.desktop (created when one
>>>>>> clicks Save in LXRandR) and thinking about how I could create
>>>>>> something that would cause Fn-F7 to toggle through the LVDS, VGA
>>>>>> and S-Video outputs, but your approach -- simply binding to
>>>>>> LXRandR -- is a MUCH better idea!
>>>>>>
>>>>>> And if I wanted to add the ability to extend the desktop instead
>>>>>> of mirroring it, I could install arandr and just bind to that
>>>>>> instead.
>>>>>>
>>>>>> On 4/29/2014 3:18 PM, Andre Rodovalho wrote:
>>>>>>>
>>>>>>> 2014-04-29 16:13 GMT-03:00 Andre Rodovalho
>>>>>>> <andre.rodovalho at gmail.com <mailto:andre.rodovalho at gmail.com>>:
>>>>>>>
>>>>>>> On lubuntu-rc.xml I do:
>>>>>>>
>>>>>>> <keybind key="XF86Display">
>>>>>>> <action name="Execute">
>>>>>>> <command>lxrandr</command>
>>>>>>> </action>
>>>>>>> </keybind>
>>>>>>>
>>>>>>> *lxrandr* deals with additional monitors, you just enable
>>>>>>> them an apply.
>>>>>>>
>>>>>>> Hope that helps! To test the shortcuts without restarting
>>>>>>> all the system you can restart only openbox: *openbox --restart*
>>>>>>>
>>>>>>>
>>>>>>> 2014-04-28 22:03 GMT-03:00 Israel <israeldahl at gmail.com
>>>>>>> <mailto:israeldahl at gmail.com>>:
>>>>>>>
>>>>>>> On 04/28/2014 07:48 PM, John Hupp wrote:
>>>>>>> > I was trying to watch Netflix on a laptop (with
>>>>>>> Lubuntu) connected to
>>>>>>> > a TV by S-Video connection. I found out that Fn-F7
>>>>>>> was not working to
>>>>>>> > select the external VGA or S-Video displays.
>>>>>>> >
>>>>>>> > Subsequently I found that Fn-F4 does not put the
>>>>>>> laptop to sleep, and
>>>>>>> > Fn-F5 does not toggle the WiFi radio on/off. (The
>>>>>>> other common
>>>>>>> > special keys work OK.)
>>>>>>> >
>>>>>>> > So I'm trying to get those keys working that way via
>>>>>>> entries in
>>>>>>> > lubuntu-rc.xml.
>>>>>>> >
>>>>>>> > With 'xev -event keyboard' I found out that Fn-F7
>>>>>>> produces the keysym
>>>>>>> > 'XF86Display' but I still need to know what command to
>>>>>>> bind that to.
>>>>>>> > So that's my first question.
>>>>>>> >
>>>>>>> > Fn-F4 and Fn-F5 does not produce any keysym's, so I'm
>>>>>>> currently at a
>>>>>>> > loss for how to proceed next with those.
>>>>>>> >
>>>>>>> >
>>>>>>> Hi,
>>>>>>>
>>>>>>> you can use arandr to make a shell script to switch the
>>>>>>> display to a
>>>>>>> certain mode. Plug in the monitor and use arandr to
>>>>>>> make a setup you
>>>>>>> want, and save that. Then open your config file for
>>>>>>> openbox and set
>>>>>>> the keyboard shortcut for your display key (i.e.
>>>>>>> XF86Display)
>>>>>>> to execute the
>>>>>>> <command>
>>>>>>> /bin/bash /path/to/scriptname.sh
>>>>>>> </command>
>>>>>>> while scriptname.sh is whatever you saved the setup as
>>>>>>> with the correct
>>>>>>> path.
>>>>>>>
>>>>>>> arandr is a front-end for xrandr. So the script is
>>>>>>> actually using
>>>>>>> xrandr to modify your display settings.
>>>>>>>
>>>>>>> I hope this helps.
>>>>>>>
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ubuntu.com/archives/lubuntu-users/attachments/20140506/ed71c893/attachment.html>
More information about the Lubuntu-users
mailing list