Getting special keys to work
John Hupp
lubuntu at prpcompany.com
Wed Apr 30 21:45:36 UTC 2014
Nice find.
Recent travels brought me to
http://askubuntu.com/questions/339842/xubuntu-hotkey-for-immediate-shutdown,
because I was looking for xfce commands to do the job, but it also has
this dbus-send command, which I just used to shut down a machine without
root privileges:
dbus-send --system --print-reply --dest=org.freedesktop.ConsoleKit
/org/freedesktop/ConsoleKit/Manager org.freedesktop.ConsoleKit.Manager.Stop
That page has also has desirable-looking xfce4-session-logout commands
(everything we would want), but they rely on a package not installed on
Lubuntu, and lxsession-logout does not yet support any parallel options.
Needless to say, on account of the success with the dbus-send shutdown
command, I am now looking hard at dbus-send:
http://manpages.ubuntu.com/manpages/trusty/man1/dbus-send.1.html
On 4/30/2014 5:14 PM, Andre Rodovalho wrote:
> http://sourcecodebrowser.com/lxsession/0.4.3/lxsession-logout_8c.html
>
> *dbus* seems to have control... I have no idea on how can you control
> dbus, but my guess it you will need root...
>
>
> 2014-04-30 17:55 GMT-03:00 Andre Rodovalho <andre.rodovalho at gmail.com
> <mailto:andre.rodovalho at gmail.com>>:
>
> I know *lxsession-logout* gives us that logout window which
> hibernate, suspend and others are available... I tried to insert
> some commands but I had no luck. Maybe you can search this
> lxssession-logout documentation or it's source code...
>
> *lxsession-default quit* triggers to lxsession-logout...
>
>
> 2014-04-30 17:11 GMT-03:00 John Hupp <lubuntu at prpcompany.com
> <mailto:lubuntu at prpcompany.com>>:
>
> 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
>>
>> And then:
>>
>> chown root:root toggle-wifi.sh
>> chmod 4755 toggle-wifi.sh
>>
>> I also tried inserting 'sudo command' in front of the rfkill
>> commands in toggle-wifi.sh, and I tried 'sudo command
>> toggle-wifi.sh' in the lubuntu-rc.xml command statement.
>>
>> 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).
>>>>
>>>> Is there more current documentation for this task? Is
>>>> ibus-setup supposed to handle this job somehow under
>>>> Lubuntu 14.04? Or is there another place preferred for
>>>> auto-starting setkeycodes commands?
>>>>
>>>> On 4/29/2014 3:54 PM, John Hupp wrote:
>>>>> Thanks, Andre, for all of those great tips.
>>>>>
>>>>> 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:
>>>>>> I tested here, and it works:
>>>>>> http://askubuntu.com/questions/181390/what-is-the-command-for-sleep-hibernate
>>>>>>
>>>>>> |*pm-suspend* and**||*pm-hibernate*|
>>>>>>
>>>>>>
>>>>>> 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.
>>>>>>
>>>>>> I'm not sure what commands you can execute to sleep
>>>>>> and hibernate, but you can control radio with
>>>>>> *rfkill*. I'm not sure if those commands really
>>>>>> require root access, but on that case you can do a:
>>>>>> *gksu command*
>>>>>> *
>>>>>> *
>>>>>> 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.
>>>>>>
>>>>>> --
>>>>>> Regards
>>>>>>
>>>>>>
>>>>>> --
>>>>>> Lubuntu-users mailing list
>>>>>> Lubuntu-users at lists.ubuntu.com
>>>>>> <mailto:Lubuntu-users at lists.ubuntu.com>
>>>>>> Modify settings or unsubscribe at:
>>>>>> https://lists.ubuntu.com/mailman/listinfo/lubuntu-users
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>>
>>>
>>>
>>>
>>
>>
>>
>
>
> --
> Lubuntu-users mailing list
> Lubuntu-users at lists.ubuntu.com
> <mailto:Lubuntu-users at lists.ubuntu.com>
> Modify settings or unsubscribe at:
> https://lists.ubuntu.com/mailman/listinfo/lubuntu-users
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ubuntu.com/archives/lubuntu-users/attachments/20140430/7808c901/attachment-0001.html>
More information about the Lubuntu-users
mailing list