understanding X keyboard mappings, audio keys and fluxbox - audio

So, I'm trying to set up fluxbox to work with my Dell keyboard which has a bunch of extra keys on it for web browsing and audio control.
I did this in my .fluxbox/keys file, and it's mostly working to control cmus.
# Music in cmus
XF86AudioPlay :Exec cmus-remote --pause
XF86AudioPause :Exec cmus-remote --pause
XF86AudioStop :Exec cmus-remote --stop
XF86AudioNext :Exec cmus-remote --next
XF86AudioPrev :Exec cmus-remote --prev
But, the stop key doesn't work. So I use showkey on it...
keycode 166 press
keycode 166 release
and it tells me that the stop key is keycode 166. According to xmodmap...
xmodmap -pke | grep 166
keycode 166 = XF86Back NoSymbol XF86Back
that is XF86Back, but mapping that in my keys file doesn't work either. More disturbing, the play/pause key, which is already working, is supposedly keycode 164, which xmodmap says is...
xmodmap -pke | grep 164
keycode 164 = XF86Favorites NoSymbol XF86Favorites
when I expectted it to be XF86AudioPlay, which is supposedly...
xmodmap -pke | grep AudioPlay
keycode 172 = XF86AudioPlay XF86AudioPause XF86AudioPlay XF86AudioPause
keycode 208 = XF86AudioPlay NoSymbol XF86AudioPlay
keycode 215 = XF86AudioPlay NoSymbol XF86AudioPlay
one of those. So...
...what's going on? Why is play/pause working if it's the wrong keycode, and is it the wrong keycode? Being a Dell keyboard, I expect all kinds of problems, since Dell in their infinite wisdom always liked to deviate from standards.
Thanks,
Mike

Related

Alt keys in xdotool?

How to simulate left and right alt key presses with xdotool?
Have tried variations of the following in command line and scripts:
xdotool keydown Alt_R key Alt_L ; sleep 1 ; xdotool keyup Alt_R
xdotool key Alt_R+Alt_L ; sleep 1 ; xdotool keyup Alt
xdotool keydown Alt_R+Alt_L ; xdtool keyup Alt_R+Alt_L
xdotool keydown Alt_R ; xdotool keydown Alt_L ; xdotool keyup Alt_R ; xdotool keyup Alt_l
etc, etc, ad nauseum.
Phrasing doesn't seem to matter; unable to simulate both left and right alt keys together. Anybody know the "proper" way to construct this?

change the keymapping under linux

Target
make my system keymapping works in a way like vim;
I want the cursor move down when pressing windowsKey + j
I want the cursor move up when pressing windowsKey + k
I want the cursor move right when pressing windowsKey + l
I want the cursor move left when pressing windowsKey + h
Solution
Using xmodmap tool
Result
Failed.
Here I'll give you some information:
I try to change the keymapping using this command under the shell
xmodmap -e "keycode 44 = 1 2 3 4 5 6 7 8"
This command succeed, and the j and J is mapped to 1 and 2
But that's not enough,the windowsKey + j is not changed at all.
When pressing windowsKey + j, it gives me an 1 insted of 7
that's not what I want
Specifics:
OS:Centos 6.4 (64 bit) with gnome 2.28.2
And the output of xmodmap -pm
shift Shift_L (0x32), Shift_R (0x3e)
lock Caps_Lock (0x42)
control Control_L (0x25), Control_R (0x69)
mod1 Alt_L (0x40), Alt_R (0x6c), Meta_L (0xcd)
mod2 Num_Lock (0x4d)
mod3
mod4 Super_L (0x85), Super_R (0x86), Super_L (0xce), Hyper_L (0xcf)
mod5 ISO_Level3_Shift (0x5c), Mode_switch (0xcb)
Question
If there is other ways to change the keymapping or you can tell me where I'm wrong
Please let me know
The reactions for keyboard events are specific for whatever programs are interpreting them.
If you're looking for a way to make command line editing work like vi, then you might get closer to what you want, with Bourne Again Shell at least, with set -o vi and then mapping the windows keys to escape (in order to enter vi edit mode) with xmodmap -e 'keycode 133 = Escape' -e 'keycode 134 = Escape'.
For other programs there are other ways to make this work, but cursor movement in v

Vimrc mapping not behaving as expected

I have created a mapping in visual and normal mode to expedite moving around in a local region of code. if i press 1+direction key it is remapped to 10 instead of 1.
vmap 1j 10j | vmap 1k 10k | vmap 1h 10h | vmap 1l 10l
nmap 1j 10j | nmap 1k 10k | nmap 1h 10h | nmap 1l 10l
This works well. However when I am typing fast I inadvertently type 11 instead of 1 so '11j' insead of '1j'. This is moving me 110 lines down instead of 11.
I would like to only move 11 in a given direction instead of 110 when I make this mistake.
Vim is interpreting this as a 1 and then adding my mapping to get the 110. Similarly if I type '21j' it is interpreted as '210j'.
This should do what you. However I'm not really sure why it works the way it does. It seems that the old count doesn't get cleared when you change the count inside the mapping and the the new count is appended to the old count. (Notice that I only put a 0 in the mapping not a 10)
I also used v:count to find the count of the mapping instead of overloading 1j. v:count returns 0 if no count was specified.
function TenMovement(type)
if v:count == 1
return '0'.a:type
else
return a:type
endif
endfunction
nnoremap <expr> j TenMovement('j')
nnoremap <expr> k TenMovement('k')
nnoremap <expr> l TenMovement('l')
nnoremap <expr> h TenMovement('h')
vnoremap <expr> j TenMovement('j')
vnoremap <expr> k TenMovement('k')
vnoremap <expr> l TenMovement('l')
vnoremap <expr> h TenMovement('h')
To fix this, you have to abort the previously typed count. <C-\><C-n> works like <Esc> in normal mode, but avoids the beep when there's no pending count:
nmap 1j <C-\><C-n>10j
For visual mode, the selection needs to be re-established with gv:
vmap 1j <C-\><C-n>gv10j

VIM - map # (number sign) to "search selected" in visual mode

I'm struggling to map # to search selected in visual. What I've tried so far was vnoremap <silent> <#> y<ESC>/^R0<CR> (y ank selected, search / from ^R egister 0 and hit CR ), but it does not work. What is the right way to do this?
vnoremap # y/<C-r>0<CR>
# instead of <#>, <Esc> is redundant after y, and ^R should be <C-r>.

jump to the first nonblank character in vim inside tmux

I have this function in my vimrc to jump to the first nonblank character on the line:
function! SmartHome()
let s:col = col(".")
normal! ^
if s:col == col(".")
normal! 0
endif
endfunction
This works well outside of a tmux session.
But inside of a tmux session it will just jump to the first character on the line - which is wrong!
I have mapped this function this way:
" smart home function
nnoremap <silent> <Home> :call SmartHome()<CR>
inoremap <silent> <Home> <C-O>:call SmartHome()<CR>
How can I solve this?
I could solve this problem by removing the following line from my .bashrc file
export TERM=xterm-256color
This works since xterm and the screen "like" protocol from tmux does not send/expect the same values for the HOME key:
$ tput -T screen khome | xxd
0000000: 1b5b 317e .[1~
$ tput -T xterm khome | xxd
0000000: 1b4f 48 .OH

Resources