Puppy Linux Discussion Forum Forum Index Puppy Linux Discussion Forum
Puppy HOME page : puppylinux.com
"THE" alternative forum : puppylinux.info
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

The time now is Wed 15 Aug 2018, 01:37
All times are UTC - 4
 Forum index » House Training » Users ( For the regulars )
Link script to specific key on keyboard? [SOLVED]
Moderators: Flash, Ian, JohnMurga
Post new topic   Reply to topic View previous topic :: View next topic
Page 1 of 1 [11 Posts]  
Author Message
Mike Walsh


Joined: 28 Jun 2014
Posts: 4012
Location: King's Lynn, UK.

PostPosted: Fri 09 Feb 2018, 11:27    Post subject:  Link script to specific key on keyboard? [SOLVED]
Subject description: Want to set things up so a little-used key on my keyboard will start a script...
 

Afternoon, boys & girls.

Need a little bit of advice here.

I'd like to set things up so the the 'Pause' key on my keyboard will start a specific script, but I'm unsure quite how you'd do this. I've tried using 'xmodmap', but I believe that's mostly for re-mapping keys so that one key will take over the functionality of another, so.....I don't think that's what I want.

I know there's a way of doing this, but I really don't know where to look for it.

Any advice will, as always, be very much appreciated. TIA.


Mike. Wink

_________________
MY PUPPY PACKAGES | 'Thanks' are always appreciated!
--------------------------------------


Last edited by Mike Walsh on Fri 09 Feb 2018, 16:22; edited 1 time in total
Back to top
View user's profile Send private message Visit poster's website 
jafadmin

Joined: 19 Mar 2009
Posts: 832

PostPosted: Fri 09 Feb 2018, 13:12    Post subject:  

I think it varies depending on which WM you're talking about. I have only ever done it on JWM.

So, with JWM there is a /root/.jwm/jwmrc-personal file in xml notation that handles the key mappings:
Code:

# execute the script "killwireless" when Ctl+Alt+k is pressed:
<Key mask="CA" key="k">exec:killwireless</Key>

# start browser when "internet" button on keyboard is pressed
<Key keycode="236">exec:defaultbrowser</Key>


You would need to know the keycode numbers for the special keys.


That's all I got ..
Back to top
View user's profile Send private message 
Mike Walsh


Joined: 28 Jun 2014
Posts: 4012
Location: King's Lynn, UK.

PostPosted: Fri 09 Feb 2018, 14:05    Post subject:  

Hiya, jafa.

Ah, that's fair enough; I'm JWM all the way in any case.

I had a look at /etc/xdg/templates/_root_.jwmrc, but wasn't sure about the 'mask' lines. I tried it with the 'key' lines directly above, and nothing happened.

I'll give it another try, and let ya know what happens.

Cheers.


Mike. Wink

_________________
MY PUPPY PACKAGES | 'Thanks' are always appreciated!
--------------------------------------

Back to top
View user's profile Send private message Visit poster's website 
Mike Walsh


Joined: 28 Jun 2014
Posts: 4012
Location: King's Lynn, UK.

PostPosted: Fri 09 Feb 2018, 16:20    Post subject:  

Hi again, jafa.

That's fixed it; something you mentioned in your example which I forgot to add to my original attempt.

Linking to here, frenchiveruti's 'suspend' script works nicely for me in several of my Pups. As you can see, I've also taken the modern 'logout_GUI' and modified it with a 'Suspend to RAM' button.....and used this in a few older Pups that used to have the old-style Logout sub-menu in the main Menu.

I was just curious to see if suspend could be triggered directly via a single key-press, rather than bringing up the LogOut_GUI to do so. Earlier on (in /etc/xdg/templates _root_.jwmrc), I tried

Code:
<Key key="Pause">/usr/sbin/suspend.sh</Key>


.....which didn't do anything. Looking at your example, I then tried

Code:
<Key key="Pause">exec:suspend.sh</Key>


.....and that works beautifully, after running 'fixmenus' and re-starting 'X'. It was the 'exec:' that made the difference.....I mistakenly assumed that pointing to an executable script would automatically run it, but of course, you need to tell it to run upon the key press, don't you?

So; a single press of the Pause key now puts Pup to sleep.....and, rather than frenchiveruti said about 'waking up' with the power button, I find that in fact just tapping any key on the keyboard brings her back to life again.

I'm getting to be a right lazy bugger, I really am..! Thanks for the pointers, mate.

----------------------

Just out of curiosity, how d'you find out the 'keycodes'? Someone on LinuxQuestions mentioned xev earlier on...? I fancy trying to get the 'multimedia' keys on this new wireless keyboard working.....


Mike. Wink

Last edited by Mike Walsh on Fri 09 Feb 2018, 17:13; edited 1 time in total
Back to top
View user's profile Send private message Visit poster's website 
jafadmin

Joined: 19 Mar 2009
Posts: 832

PostPosted: Fri 09 Feb 2018, 16:39    Post subject:  

Done & dusted, mate ..
Back to top
View user's profile Send private message 
Mike Walsh


Joined: 28 Jun 2014
Posts: 4012
Location: King's Lynn, UK.

PostPosted: Fri 09 Feb 2018, 17:19    Post subject:  

jafadmin wrote:
Done & dusted, mate ..


@jafadmin:-

Look at the end of my previous post. I added that bit, but didn't post it for a while; I was in the middle of doing summat else, and forgot to submit it!

Do you happen to know how you can find out keycodes for the whole keyboard? I know Pup has xev (seems to be part of Busybox), but I don't have a clue as to how you use it.....and research hasn't thrown up a lot of help, either. Even the man page doesn't really make it clear what you do with it...


Mike. Wink

_________________
MY PUPPY PACKAGES | 'Thanks' are always appreciated!
--------------------------------------

Back to top
View user's profile Send private message Visit poster's website 
jafadmin

Joined: 19 Mar 2009
Posts: 832

PostPosted: Fri 09 Feb 2018, 21:19    Post subject:  

Try: "showkey -k" from a console. Just start it then press the key you are interested in. It will show you the Press and Release codes (which are usually the same).

"showkey" is a standard part of X
Back to top
View user's profile Send private message 
Marv


Joined: 04 May 2005
Posts: 1067
Location: SW Wisconsin

PostPosted: Fri 09 Feb 2018, 22:09    Post subject:  

Mike Walsh wrote:

Just out of curiosity, how d'you find out the 'keycodes'? Someone on LinuxQuestions mentioned xev earlier on...? I fancy trying to get the 'multimedia' keys on this new wireless keyboard working.....
I run "xev -event_mask keyboard" in terminal. To get out as it traps and displays all keys quit the little auxilliary window it opens. A bit clunky but works...
_________________
Pups currently in kennel Very Happy LxPupSc and X-slacko-4.4 for my users; LxPupSc, LxPupSc64, and LxPupBB for me. All good pups indeed, and all running savefiles for look'n'feel only. Browsers, etc. solely from SFS. Now tazpup for puzzles Smile
Back to top
View user's profile Send private message 
MochiMoppel


Joined: 26 Jan 2011
Posts: 1571
Location: Japan

PostPosted: Fri 09 Feb 2018, 22:19    Post subject:  

jafadmin wrote:
So, with JWM there is a /root/.jwm/jwmrc-personal file in xml notation that handles the key mappings:
Code:

# execute the script "killwireless" when Ctl+Alt+k is pressed:
<Key mask="CA" key="k">exec:killwireless</Key>

# start browser when "internet" button on keyboard is pressed
<Key keycode="236">exec:defaultbrowser</Key>
Hmmm... that would not be XML notation.

I recommend to use XML <!-- comments -->
Or you could use bash comments as part of the shell command:
Code:
<Key mask="CA" key="k">exec:killwireless # any comment could be added here</Key>
Back to top
View user's profile Send private message 
jafadmin

Joined: 19 Mar 2009
Posts: 832

PostPosted: Fri 09 Feb 2018, 23:12    Post subject:  

@MochiMoppel

You are right. I added the comments in that post for description reasons. In the actual file they don't exist ..
Back to top
View user's profile Send private message 
musher0


Joined: 04 Jan 2009
Posts: 12556
Location: Gatineau (Qc), Canada

PostPosted: Sat 10 Feb 2018, 08:23    Post subject:
Subject description: So non-jwm users do not feel let down...
 

Hello Mike_Walsh and all.

I would like to add, for the benefit of anyone who believes in the principle of
"freedom of window managers", that the ROX Pinboard, aka PuppyPin on Puppy,
has a hot key manager.

The difference with the jwm solution is that such hot key will be associated with an
icon on the ROX pinboard. The syntax is as follows:
Quote:
[two spaces]<icon x="some number" y="some number" label="something" shortcut="hot key here">command/with/path</icon
E.g., this is the line in it for the "Root" icon that Puppies usually have at the top
left corner of their screen. I have associated to it the hot key "Ctrl-Shift-r".
Code:
  <icon x="80" y="96" label="file" shortcut="Control+Shift+r">/usr/local/bin/defaultfilemanager</icon>
The regular user does not have to enter this code manually, although bash scripters
really appreciate the possibility.

All the user has to do is
-- drag the application on the desktop if it is not already there; an icon is created;
-- right-click on the icon and click "edit item";
-- a small panel appears over the icon;
-- if you wish to change the hot key, click the longish button above word "locked";
-- a small rectangle is shown at the middle of the screen;
-- now type the hot key combination
-- click "ok".
(Please see attached composite image.)
That's all.

This ROX-based solution is independent of any window manager you may use on
your Puppy. A word of warning, though: with the ROX pinboard hot keys, there often
needs to be an app on screen for them to work. I never could explain this fanciful
behavior in ROX, but it exists. It is as if the ROX hot keys will not work in a Puppy
session until a ROX window has been opened. My solution is to have at all times
the ROX window for the ~ (root) directory open on one of the desktops.

~~~~~~~~~~~~~~

Speaking of window managers, the icewm and pekwm window managers have hot
key files. That I know of! Please be aware that quite a few window managers come
with a hot-key utility or configuration file.

The syntax for icewm is very simple:
Quote:
key "hot key" application
If you are using icewm, type
Code:
cat ~/.icewm/keys | more
to get examples. Icewm's key combos are contained in a simple text file.

pekwm also uses a simple text file as a container for its hot keys. Its syntax is
more involved than icewm's, but still quite understandable: As an example, the
command to lauch XLock is:
Code:
        KeyPress = "Ctrl Mod1 L" { Actions = "Exec xlock &" }
"Mod1" being the left Alt key. In pekwm you can define such important keys.
Pekwm users can type
Code:
cat ~/.pekwm/keys | more
for more examples.

Another warning: if you have hot keys for the ROX pinboard icons and for your
window manager, the ones in the WM usually have precedence. The best way to
avoid snafus is to make sure the hot key you intend to use is only used once,
either in the ROX pinboard OR in the window manager hot key file.

~~~~~~~~~~~~~~

These warnings bring me to a dedicated utility that, IIRC ( I have not used it in a
while), usually overrides other hot key managers, either WMs or ROX, because you
launch it before them.

The xbindkeys utility has made managing hot keys a specialty. From its
web page:
Quote:
xbindkeys is a program that allows you to launch shell commands with your
keyboard or your mouse under X Window. It links commands to keys or mouse
buttons, using a configuration file. It's independant of the window manager and can
capture all keyboard keys (ex: Power, Wake...).
This forum has six pages of references if you ask it to search "xbindkeys", but this
post by forum member MU is a classic, IMO.

~~~~~~~~~~~~~~

I hope this little roundup of "hot keys" solutions will help Puppy users.

BFN.
composite.jpg
 Description   How to associate a hot key with a program icon in the ROX pinboard (aka PuppyPin).
This is a composite; the key stroke box is by default in the middle of the screen.
 Filesize   110.36 KB
 Viewed   41 Time(s)

composite.jpg


_________________
musher0
~~~~~~~~~~
Siempre será canción nueva... (V. Jara, Manifiesto)
Back to top
View user's profile Send private message 
Display posts from previous:   Sort by:   
Page 1 of 1 [11 Posts]  
Post new topic   Reply to topic View previous topic :: View next topic
 Forum index » House Training » Users ( For the regulars )
Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.0864s ][ Queries: 15 (0.0072s) ][ GZIP on ]