Re: [dev] hotkey (1) - a suckless global keybinder

2014-02-11 Thread Kurt Van Dijck
 Although taking a different approach (conf file parsed at start-up,
 additional features), the sxhkd/shkd might be of interest.
 The former is for X and the latter for the console. The two have
 compatible configuration files formats.
 
 https://github.com/baskerville/sxhkd
 https://github.com/baskerville/shkd

or https://github.com/patrickhaller/speckeysd

Kurt



Re: [dev] hotkey (1) - a suckless global keybinder

2014-02-11 Thread Calvin Morrison
I added hotkey config file support. It is so ugly, and requires much
more code. I am ashamed of it to be honest, but it works.

except when it segfaults if your config isn't written pefectly. i'm
working on that.



On 11 February 2014 06:07, Kurt Van Dijck
dev.k...@vandijck-laurijssen.be wrote:
 Although taking a different approach (conf file parsed at start-up,
 additional features), the sxhkd/shkd might be of interest.
 The former is for X and the latter for the console. The two have
 compatible configuration files formats.

 https://github.com/baskerville/sxhkd
 https://github.com/baskerville/shkd

 or https://github.com/patrickhaller/speckeysd

 Kurt




Re: [dev] hotkey (1) - a suckless global keybinder

2014-02-10 Thread Michael Hauser
Thank you for this little gem!

A humble feature request: add the ability to have modal keybindings /
modes as in vim(1), etc…

Maybe someone with more experience could combine the superb keymodes
patch with this?

After hacking the code myself a little I am struck at implementing it
myself, as the whole X11/event system seems to be designed to make my
brain rot. :)

Well, your nice addition to the suckless tools has all in all made my
day, so thx again!

cheers, mih

On 2/9/14, Calvin Morrison mutanttur...@gmail.com wrote:
 This is great! I was just having a discussion about someone for a
 non-x11 keyboard binding system!

 Thanks for the link

 Calvin Morrison

 On 9 February 2014 05:32, Raphaël Proust raphla...@gmail.com wrote:
 Although taking a different approach (conf file parsed at start-up,
 additional features), the sxhkd/shkd might be of interest.
 The former is for X and the latter for the console. The two have
 compatible configuration files formats.

 https://github.com/baskerville/sxhkd
 https://github.com/baskerville/shkd

 Cheers,
 --
 __
 Raphaël Proust


 On Sat, Feb 8, 2014 at 11:37 PM, Calvin Morrison mutanttur...@gmail.com
 wrote:
 Why wasn't there a simple way to have hotkeys, dealt with properly, in
 a suckless manner? I don't want inane bindings for every WM, I don't
 even want my wm controlling my hotkeys! So I wrote it.






Re: [dev] hotkey (1) - a suckless global keybinder

2014-02-10 Thread Calvin Morrison
I'm not sure what you mean by modal bindings. Do you mean like
executing a hotkey like Ctrl+: to jump the hotkey program, then
pressing another key to execute a command? Sorry I'm not sure what you
are saying.

Calvin

On 10 February 2014 17:02, Michael Hauser awarewa...@gmail.com wrote:
 Thank you for this little gem!

 A humble feature request: add the ability to have modal keybindings /
 modes as in vim(1), etc...

 Maybe someone with more experience could combine the superb keymodes
 patch with this?

 After hacking the code myself a little I am struck at implementing it
 myself, as the whole X11/event system seems to be designed to make my
 brain rot. :)

 Well, your nice addition to the suckless tools has all in all made my
 day, so thx again!

 cheers, mih

 On 2/9/14, Calvin Morrison mutanttur...@gmail.com wrote:
 This is great! I was just having a discussion about someone for a
 non-x11 keyboard binding system!

 Thanks for the link

 Calvin Morrison

 On 9 February 2014 05:32, Raphaël Proust raphla...@gmail.com wrote:
 Although taking a different approach (conf file parsed at start-up,
 additional features), the sxhkd/shkd might be of interest.
 The former is for X and the latter for the console. The two have
 compatible configuration files formats.

 https://github.com/baskerville/sxhkd
 https://github.com/baskerville/shkd

 Cheers,
 --
 __
 Raphaël Proust


 On Sat, Feb 8, 2014 at 11:37 PM, Calvin Morrison mutanttur...@gmail.com
 wrote:
 Why wasn't there a simple way to have hotkeys, dealt with properly, in
 a suckless manner? I don't want inane bindings for every WM, I don't
 even want my wm controlling my hotkeys! So I wrote it.







Re: [dev] hotkey (1) - a suckless global keybinder

2014-02-10 Thread Michael Hauser
Calvin Morrison writes:
 I'm not sure what you mean by modal bindings. Do you mean like
 executing a hotkey like Ctrl+: to jump the hotkey program, then
 pressing another key to execute a command? Sorry I'm not sure what you
 are saying.
 
 Calvin

Exactly!

Use case: one hotkey (in my case: the useless '' key on german
keyboards) to activate a, let's call it COMMAND mode :), maybe a litte
visual hint (I'm making the taskbar visible in dwm for now), that does
nothing else than waiting for the next keypress.

Have a look at dwm's keymodes patch, I really like this implementation.

My hacked 'hotkey' version depends on some X11/event race condition, as
I was able to figure out how to grab the whole kb for a while; but I
haven't started to dig into the keymodes patch yet; therefore my
suggestion to combine the two.

Also the goal is to have a system that can be operaten with literally
one finger alone, I think it would be a godsent for accessibility (not
just when consuming yp *ducks* :).


cheers, mih


ps. I really like the poetic license!

-- 
'aware water' is an anagram for 'we are at war'



Re: [dev] hotkey (1) - a suckless global keybinder

2014-02-10 Thread Calvin Morrison
make a hidden window, and set the window focus to it? that'd be my
guess. I don't think you can grab two non modifier keys though,  and
 for example probably wouldn't work with the way I am grabbing it.
I'd love too see some code.

A visual hint could be nice. I definitely see the advantage of a modal
system because there are already so many shortcuts you can
accidentally interfere with,having just one to interfere with reduces
the issue.

but then why not just use my program to launch a script with dmenu
(vertical version) and have a keybinding for that? eg:

ALT+P spawns dmenu
dmenu shows
1. mocp -g
2. xterm
3. firefox

you press 3 and enter and it executes..?

what do you think of that?

On 10 February 2014 18:24, Michael Hauser awarewa...@gmail.com wrote:
 Calvin Morrison writes:
 I'm not sure what you mean by modal bindings. Do you mean like
 executing a hotkey like Ctrl+: to jump the hotkey program, then
 pressing another key to execute a command? Sorry I'm not sure what you
 are saying.

 Calvin

 Exactly!

 Use case: one hotkey (in my case: the useless '' key on german
 keyboards) to activate a, let's call it COMMAND mode :), maybe a litte
 visual hint (I'm making the taskbar visible in dwm for now), that does
 nothing else than waiting for the next keypress.

 Have a look at dwm's keymodes patch, I really like this implementation.

 My hacked 'hotkey' version depends on some X11/event race condition, as
 I was able to figure out how to grab the whole kb for a while; but I
 haven't started to dig into the keymodes patch yet; therefore my
 suggestion to combine the two.

 Also the goal is to have a system that can be operaten with literally
 one finger alone, I think it would be a godsent for accessibility (not
 just when consuming yp *ducks* :).


 cheers, mih


 ps. I really like the poetic license!

 --
 'aware water' is an anagram for 'we are at war'




Re: [dev] hotkey (1) - a suckless global keybinder

2014-02-10 Thread Calvin Morrison
On 10 February 2014 18:31, Calvin Morrison mutanttur...@gmail.com wrote:
 make a hidden window, and set the window focus to it? that'd be my
 guess. I don't think you can grab two non modifier keys though,  and
 for example probably wouldn't work with the way I am grabbing it.
 I'd love too see some code.

 A visual hint could be nice. I definitely see the advantage of a modal
 system because there are already so many shortcuts you can
 accidentally interfere with,having just one to interfere with reduces
 the issue.

 but then why not just use my program to launch a script with dmenu
 (vertical version) and have a keybinding for that? eg:

 ALT+P spawns dmenu
 dmenu shows
 1. mocp -g
 2. xterm
 3. firefox

 you press 3 and enter and it executes..?

 what do you think of that?

 On 10 February 2014 18:24, Michael Hauser awarewa...@gmail.com wrote:
 Calvin Morrison writes:
 I'm not sure what you mean by modal bindings. Do you mean like
 executing a hotkey like Ctrl+: to jump the hotkey program, then
 pressing another key to execute a command? Sorry I'm not sure what you
 are saying.

 Calvin

 Exactly!

 Use case: one hotkey (in my case: the useless '' key on german
 keyboards) to activate a, let's call it COMMAND mode :), maybe a litte
 visual hint (I'm making the taskbar visible in dwm for now), that does
 nothing else than waiting for the next keypress.

 Have a look at dwm's keymodes patch, I really like this implementation.

 My hacked 'hotkey' version depends on some X11/event race condition, as
 I was able to figure out how to grab the whole kb for a while; but I
 haven't started to dig into the keymodes patch yet; therefore my
 suggestion to combine the two.

 Also the goal is to have a system that can be operaten with literally
 one finger alone, I think it would be a godsent for accessibility (not
 just when consuming yp *ducks* :).


 cheers, mih


 ps. I really like the poetic license!

 --
 'aware water' is an anagram for 'we are at war'


and here it is:

$ cat modal.sh
list=firefox
chromium
xterm
xterm -e mocp
v=0
`for i in $list; do echo $v $i; v=$(($v+1));  done | dmenu -l 5 |
sed 's/^[0-9] //g'`

now it has some kinks, the whole for i in whatever in bash doesn't
work quite properly becaue it works on spaces and newlines... not sure
what to do about that. but i am sure there's a bash way to do it.



Re: [dev] hotkey (1) - a suckless global keybinder

2014-02-10 Thread Michael Hauser
Calvin Morrison writes:
 make a hidden window, and set the window focus to it? that'd be my
 guess. I don't think you can grab two non modifier keys though,  and
  for example probably wouldn't work with the way I am grabbing it.
 I'd love too see some code.

Yes, I tried to load/unload the grabs as needed in my ugly hack :)

 
 A visual hint could be nice. I definitely see the advantage of a modal
 system because there are already so many shortcuts you can
 accidentally interfere with,having just one to interfere with reduces
 the issue.

I like this idea, but unfortunately it's beyond my understanding of the
X11 system;  Though I'd love it, if someone could point me in some
proper direction for example/tutorial code.

 
 but then why not just use my program to launch a script with dmenu
 (vertical version) and have a keybinding for that? eg:

Simply put: I think this approach is too slow.  I dabbled with dmenu and
too many keys hit just get lost, while starting up dmenu.

 
 ALT+P spawns dmenu
 dmenu shows
 1. mocp -g
 2. xterm
 3. firefox
 
 you press 3 and enter and it executes..?
 
 what do you think of that?
 

Muscle memory is really fast, the idea is a good one, but I believe even
with prelinking dmenu's libs it wouldn't be as efficient as a standalone
utility.


cheers, mih

ps. sorry about my rusty active english skills :)

 On 10 February 2014 18:24, Michael Hauser awarewa...@gmail.com wrote:
  Calvin Morrison writes:
  I'm not sure what you mean by modal bindings. Do you mean like
  executing a hotkey like Ctrl+: to jump the hotkey program, then
  pressing another key to execute a command? Sorry I'm not sure what you
  are saying.
 
  Calvin
 
  Exactly!
 
  Use case: one hotkey (in my case: the useless '' key on german
  keyboards) to activate a, let's call it COMMAND mode :), maybe a litte
  visual hint (I'm making the taskbar visible in dwm for now), that does
  nothing else than waiting for the next keypress.
 
  Have a look at dwm's keymodes patch, I really like this implementation.
 
  My hacked 'hotkey' version depends on some X11/event race condition, as
  I was able to figure out how to grab the whole kb for a while; but I
  haven't started to dig into the keymodes patch yet; therefore my
  suggestion to combine the two.
 
  Also the goal is to have a system that can be operaten with literally
  one finger alone, I think it would be a godsent for accessibility (not
  just when consuming yp *ducks* :).
 
 
  cheers, mih
 
 
  ps. I really like the poetic license!
 
  --
  'aware water' is an anagram for 'we are at war'
 
 

-- 
'aware water' is an anagram for 'we are at war'



Re: [dev] hotkey (1) - a suckless global keybinder

2014-02-10 Thread Michael Hauser
Calvin Morrison writes:

8--8--
 
 and here it is:
 
 $ cat modal.sh
 list=firefox
 chromium
 xterm
 xterm -e mocp
 v=0
 `for i in $list; do echo $v $i; v=$(($v+1));  done | dmenu -l 5 |
 sed 's/^[0-9] //g'`
 
 now it has some kinks, the whole for i in whatever in bash doesn't
 work quite properly becaue it works on spaces and newlines... not sure
 what to do about that. but i am sure there's a bash way to do it.
 

Yay thx, I have a simillar hack in 'production', that run-or-raises
apps, tmux windows, browser tabs, etc…

But I really think this should be the job of the one and only minimal
keybinding utility.

With my dmenu scripts I always have to pause myself to not run into some
weired race condition, where dmenu takes it's own time to accept the
keys I hit, after dropping them to the active client…

also: the additional Enter/Return in dmenu seems unefficient.

Generally a great approach, but not in the long term.


cheers, mih

-- 
'aware water' is an anagram for 'we are at war'



Re: [dev] hotkey (1) - a suckless global keybinder

2014-02-09 Thread Chris Down
On 2014-02-09 01:43:55 -0500, Calvin Morrison wrote:
 Surely the user knows what shell they are using? Sure it's a valid
 point, but almost irrelevant at the same time. Who cares about their
 shell behavior? If they think it's an issue, then they need not run
 any commands. I assume people are intelligent, and want to let them
 use their shells additional features, rather than retard them with
 safety.

Well, I think the fact that you have to append  after each command
about sums up my feelings on the matter.


pgpsvK__oa0LV.pgp
Description: PGP signature


Re: [dev] hotkey (1) - a suckless global keybinder

2014-02-09 Thread Bastien Dejean
Calvin Morrison:

 On 9 February 2014 01:07, Chris Down ch...@chrisdown.name wrote:
  - You are using system(), which is highly unportable and extremely
  fragile;
 
 I'm not so sure. What's a better solution?

http://lubutu.com/code/spawning-in-unix



Re: [dev] hotkey (1) - a suckless global keybinder

2014-02-09 Thread Raphaël Proust
Although taking a different approach (conf file parsed at start-up,
additional features), the sxhkd/shkd might be of interest.
The former is for X and the latter for the console. The two have
compatible configuration files formats.

https://github.com/baskerville/sxhkd
https://github.com/baskerville/shkd

Cheers,
-- 
__
Raphaël Proust


On Sat, Feb 8, 2014 at 11:37 PM, Calvin Morrison mutanttur...@gmail.com wrote:
 Why wasn't there a simple way to have hotkeys, dealt with properly, in
 a suckless manner? I don't want inane bindings for every WM, I don't
 even want my wm controlling my hotkeys! So I wrote it.



Re: [dev] hotkey (1) - a suckless global keybinder

2014-02-09 Thread Rob

On 09/02/14, Chris Down wrote:


On 2014-02-09 01:43:55 -0500, Calvin Morrison wrote:

Surely the user knows what shell they are using? Sure it's a valid
point, but almost irrelevant at the same time. Who cares about their
shell behavior? If they think it's an issue, then they need not run
any commands. I assume people are intelligent, and want to let them
use their shells additional features, rather than retard them with
safety.


Well, I think the fact that you have to append  after each command
about sums up my feelings on the matter.


I suppose it's a question of whether you'll use shell features or not.
If not, you can go with how dwm does it, and pass
(char *[]){ xterm, -e, mail, NULL } to execvp.

Regarding EXIT_SUCCESS, I think this is perhaps a bit picky, 0 is
perfectly fine and besides, every non-trivial shell script hard codes
stdout and stderr: 21.

Rob



Re: [dev] hotkey (1) - a suckless global keybinder

2014-02-09 Thread Jens Staal
On Sunday 09 February 2014 01:22:00 Calvin Morrison wrote:
 I h8 licensing schemes which make me read the text... somebody call
 their lawyer and sue, looks like mit is not 4 me.

have a look at the poetic license

http://www.genaud.net/2005/10/poetic-license/

... its cute while still saying everything that is needed.




Re: [dev] hotkey (1) - a suckless global keybinder

2014-02-09 Thread Chris Down
On 2014-02-09 14:18:01 +0100, Jens Staal wrote:
 have a look at the poetic license
 
 http://www.genaud.net/2005/10/poetic-license/
 
 ... its cute while still saying everything that is needed.

...and almost certainly not legally tested.


pgpb36Q16Si39.pgp
Description: PGP signature


Re: [dev] hotkey (1) - a suckless global keybinder

2014-02-09 Thread Calvin Morrison
This is great! I was just having a discussion about someone for a
non-x11 keyboard binding system!

Thanks for the link

Calvin Morrison

On 9 February 2014 05:32, Raphaël Proust raphla...@gmail.com wrote:
 Although taking a different approach (conf file parsed at start-up,
 additional features), the sxhkd/shkd might be of interest.
 The former is for X and the latter for the console. The two have
 compatible configuration files formats.

 https://github.com/baskerville/sxhkd
 https://github.com/baskerville/shkd

 Cheers,
 --
 __
 Raphaël Proust


 On Sat, Feb 8, 2014 at 11:37 PM, Calvin Morrison mutanttur...@gmail.com 
 wrote:
 Why wasn't there a simple way to have hotkeys, dealt with properly, in
 a suckless manner? I don't want inane bindings for every WM, I don't
 even want my wm controlling my hotkeys! So I wrote it.




Re: [dev] hotkey (1) - a suckless global keybinder

2014-02-08 Thread Chris Down
On 2014-02-08 18:37:19 -0500, Calvin Morrison wrote:
 I have had a love affair with dwm's config.h. Unfortunately I also
 love i3, and also deal with a plethora of other desktops on my day to
 day work. so I created hotkey (1).
 
 Why wasn't there a simple way to have hotkeys, dealt with properly, in
 a suckless manner? I don't want inane bindings for every WM, I don't
 even want my wm controlling my hotkeys! So I wrote it.

A few comments:

- What's with the weird inconsistent indentation? It makes your code
  really hard to read;
- You are using system(), which is highly unportable and extremely
  fragile;
- There is no author attribution for the code taken from dwm, which is
  required;
- You also failed to include the license header, which is required by
  the MIT license;
- You are using the unportable return 0 when returning from main() --
  use EXIT_SUCCESS instead.

I did not look in detail at the code, there may be more issues.


pgp0z1QzZO9_H.pgp
Description: PGP signature


Re: [dev] hotkey (1) - a suckless global keybinder

2014-02-08 Thread Calvin Morrison
On 9 February 2014 01:07, Chris Down ch...@chrisdown.name wrote:
 On 2014-02-08 18:37:19 -0500, Calvin Morrison wrote:
 I have had a love affair with dwm's config.h. Unfortunately I also
 love i3, and also deal with a plethora of other desktops on my day to
 day work. so I created hotkey (1).

 Why wasn't there a simple way to have hotkeys, dealt with properly, in
 a suckless manner? I don't want inane bindings for every WM, I don't
 even want my wm controlling my hotkeys! So I wrote it.

 A few comments:

 - What's with the weird inconsistent indentation? It makes your code
   really hard to read;

Not sure where you are reading it. My indentation is perfectly normal,
tabs mark a single level of indentation. Maybe you have a weird editor
setup or something with 16 spaces per tab?

 - You are using system(), which is highly unportable and extremely
   fragile;

I'm not so sure. What's a better solution? system() seems like a very
standard function. Portability is also not a real concern for me. mos
everybody uses linux who uses X11, if you are using something else,
well, then it's probably simple to write a patch. If there's a better
solution I am all for it though

 - There is no author attribution for the code taken from dwm, which is
   required;
 - You also failed to include the license header, which is required by
   the MIT license;

I h8 licensing schemes which make me read the text... somebody call
their lawyer and sue, looks like mit is not 4 me.

 - You are using the unportable return 0 when returning from main() --
   use EXIT_SUCCESS instead.

good catch. I usually do, though when would it ever reach that point?
while(1) loops until the process exists, so maybe removin the line
would be even better.

 I did not look in detail at the code, there may be more issues.

please do, I am unfamilar with x11's api so i probably botched it quite a bit.



Re: [dev] hotkey (1) - a suckless global keybinder

2014-02-08 Thread Chris Down
On 2014-02-09 01:22:00 -0500, Calvin Morrison wrote:
  - You are using system(), which is highly unportable and extremely
fragile;
 
 I'm not so sure. What's a better solution? system() seems like a very
 standard function. Portability is also not a real concern for me. mos
 everybody uses linux who uses X11, if you are using something else,
 well, then it's probably simple to write a patch. If there's a better
 solution I am all for it though

It's not about the function, it's about the fact that it relies on the
reparsing of that syntax in your shell, which is unknown.


pgpeyVqzloMCK.pgp
Description: PGP signature


Re: [dev] hotkey (1) - a suckless global keybinder

2014-02-08 Thread Calvin Morrison
On 9 February 2014 01:36, Chris Down ch...@chrisdown.name wrote:
 On 2014-02-09 01:22:00 -0500, Calvin Morrison wrote:
  - You are using system(), which is highly unportable and extremely
fragile;

 I'm not so sure. What's a better solution? system() seems like a very
 standard function. Portability is also not a real concern for me. mos
 everybody uses linux who uses X11, if you are using something else,
 well, then it's probably simple to write a patch. If there's a better
 solution I am all for it though

 It's not about the function, it's about the fact that it relies on the
 reparsing of that syntax in your shell, which is
Surely the user knows what shell they are using? Sure it's a valid
point, but almost irrelevant at the same time. Who cares about their
shell behavior? If they think it's an issue, then they need not run
any commands. I assume people are intelligent, and want to let them
use their shells additional features, rather than retard them with
safety.