I have a Microsoft keyboard with a series of non-standard buttons such as "Mail", "Search" , "Web/Home" etc.
It would be nice to be able to bind these keys so they execute arbitrary programs.
Does anybody know how to do this in Debian Etch?
I can't say for certain because I'm not using Debian but if you're using Gnome the easiest way is to run gnome-keybinding-properties (System > Preferences > Keyboard Shortcuts)
Instead of typing a shortcut such as Ctrl+M, hit the button on your keyboard.
If you would prefer to do this via command line or with a different desktop environment, this may help: Unusual keys and keyboards
Running Debian, I had the same issue. What I did is run xev and see what keycode those keys return. Microsoft likes to break standards a little, so some of the multimedia keys just won't work. But the ones that do will return a keycode. Then write a script with xmodmap to map those keys properly.
The Gentoo Wiki has excellent documentation on how to do these things.
I put my xmodmap script in ~/.kde/Autostart/ because I use kde, but you could just as easily put it in your home folder and have your .bashrc or .profile source it.
Once you've mapped the keycodes, you can assign those keys to specific actions in your desktop environment.
I used Gizmo Daemon for my PowerMate under Debian - it supports fancy keyboard keys as well (although I haven't tried it for those keys). Hacking on gizmod to get it to do what I wanted was pretty easy.
Gizmo Daemon
There's a few different ways to do so, the easiest generally being keytouch, which is probably available in the Debian repositories. The user manual is here. There is a chance that your keyboard won't work with it though.
If you want to do it manualy you can edit ~/.xmodmap
and use xmodmap ~/.xmodmap to apply the modifications
Related
I made a text editor and I want to port it to Linux such that I can use it remotely via SSH. I don't know much about Linux terminals, so maybe I'm missing something obvious, because I just can't believe that in 2013 there's still no way for a remote terminal to distinguish between Ctrl+M and Enter, or between Ctrl+H and Backspace, or even get any events at all for Ctrl+Left/Right/Up/Down, and so on. I tried ncurses and libtermkey to no avail. The question is, is there any effort or discussion in the Linux community on modernizing or replacing the linux terminal protocol(s) to something that supports full keyboard and mouse interaction and possibly full color, i.e. something that would allow for text user-interfaces without huge usability compromises?
As far as I know, the Linux console terminal just doesn't support this, full stop. If you want to try raising a patch, you could have a go at implementing the full CSI-encoded reporting scheme. It is documented here.
libtermkey will recognise the key sequences if sent, but the fix has to go into the terminal first of all to send them in the first place.
I'm trying to use xdebug with vim on linux. I follow the instructions to install xdebug and after that I can see the information about xdebug if I call phpinfo() from a file inside the apache server.
After open a file in vim, it is supposed that when I press F5 it should show something like "waiting for a new connection on port 9000 for 10 seconds...", but it doesn't show anything..
Any idea?
I would recommend you look at a new vim debugger plugin, called vdebug: https://github.com/joonty/vdebug -- it is actively developed and seems very capable.
I had the same sort of problem, it turned out that my terminal emulator was capturing the keypress and not sending it to vim (I think). Remapping the functions to different keys solved the problem.
It could actually be his/her keyboard. If the keyboard has mult-media functions as well as F1-F12 on them... then there is, usually a "F-Lock" key next to the row of function keys that will turn on/off the function key behavior. Really annoying, IMHO, for the new keyboards sold these days.... and rarely does the keyboard have a light to indicate the ulterior operation of said function keys.
I say this cuz, that is exactly what happened to me just now.
If I go to System Preferences, Keyboard, Keyboard Shortcuts, then Application Shortcuts, I can define custom shortcuts to be used on a Mac.
Any way to access this functionality via Applescript?
The shortcuts are stored in NSUserKeyEquivalents dictionaries in ~/Library/Preferences/.GlobalPreferences.plist and the property lists of applications.
defaults write -g NSUserKeyEquivalents -dict-add Duplicate '~#d' Minimize '\0'
defaults write com.apple.finder NSUserKeyEquivalents '{"Show Package Contents"="#\r";}'
The shortcut format is described in the Cocoa Text System article.
System Preferences isn't scriptable with Applescript natively, you have to interact with it by GUI Scripting. GUI Scripting is really a last resort that allows you to interact with controls by explicitly declaring and calling them, and it doesn't take much to throw off a GUI script. It is difficult to implement even for experienced Applescript programmers. You'll find a few introductory tutorials out there in the web, but not much else.
The internals of the Mac OS are quickly becoming a lost art. Run the following in a shell, or run via shell in Applescript:
defaults write com.google.Chrome NSUserKeyEquivalents '{ "Search the Web…" = "#k"; }'
Also good to know: shortcuts for Services are in the pbs.plist, and they're stored using a different property than the NSUserKeyEquivalents.
There's info on how to write a basic script to change/add shortcuts for Services here:
Set Services keyboard shortcut via script OSX
This was the method I found the simplest, and it worked well for me (macOS 10.12.6 Sierra):
You can also use PlistBuddy and defaults:
/usr/libexec/PlistBuddy -c 'Delete NSServicesStatus:"(null) - test2 -
runWorkflowAsService"' ~/Library/Preferences/pbs.plist
2>/dev/null;defaults write pbs NSServicesStatus -dict-add '"(null) -
test2 - runWorkflowAsService"' '{key_equivalent = "^~#2";}'
The PlistBuddy command is not needed if there is not an existing entry
for the service. Replace test2 with the name of the service. Quit and
reopen applications to apply the changes.
^~#2 is control-option-command-2. See
http://osxnotes.net/keybindings.html.
And in case this might help those who are a bit less familiar with writing/executing scripts on macOS, I saved the script as a shell script (.sh extension), and ran it from Terminal using the following commannd:
sh "/path/to/script/scriptfile.sh"
I have written an AppleScript library to programmatically add Global & Application shortcuts. It took a tremendous amount of effort to work around the various quirks in how macOS implements shortcuts.
Version 1.0 is available here:
https://forum.latenightsw.com/t/setting-other-applications-keyboard-shortcuts-using-nsuserdefaults-defaults-not-updating/3537/5
I will be making some minor API additions & changes when I find the time, and will post the source code here in full at that time. Note that as mentioned above, Services shortcuts are stored using a completely different system & are not handled here.
I'd like to be able to map the vim commands :tabnext and :tabprev to CTRL+TAB and CTRL+SHIFT+TAB respectively. Unfortunately, I seem to be running into the problem where PuTTY eats these character combinations.
I've tried searching for information, but to no avail. I'm pretty sure this is a PuTTY thing but there doesn't seem to be any sort of help/reference area for the application.
I am curious if anyone here has any experience or suggestions for figuring this out.
#rmeador: try mapping the key combo within vim.
I have attempted to do this, but it doesn't appear like vim is getting the combo. I'm not certain if this is related to the term settings or an issue with PuTTY.
PuTTY doesn't send anything when you press Ctrl+Tab.
You can patch PuTTY as it is described here: Using Ctrl+Tab in GNU Screen over PuTTY
I believe that at this time, using Ctrl+Tab is not possible with PuTTY, because PuTTY does not allow you to configure specific translations for keys. Here is a decent article that shows how you would set this up if PuTTY did support this feature:
http://www.staldal.nu/tech/2009/01/10/how-to-use-ctrl-tab-in-gnu-screen/
If you use (or would consider using) a hotkey/macro program like Autohotkey, you could emulate this behavior yourself. For example, this Autohotkey config script would do exactly what you want:
#IfWinActive PuTTY
^Tab::Send :tabnext
^+Tab::Send :tabprev
#IfWinActive
(Note that this example is just looking for any window title starting with PuTTY, so you'd have to adjust based on your title configuration.)
Is there a way to map Cmd+C to Copy in linux? (instead of Ctrl+C)
Would be nice if I could also have the emacs style ones, like Ctrl+B to move left by one character.
Is there a way, on Linux/X, to map certain key combos to other key combos?
In the tradition of all open source projects, there's not a way, there are several. At the lowest level you've got kernel keybindings, which is probably not what you want. At the X server level you've got xkb with its myriad utilities. And then it seems that every window manager - gnome, kde, xfce or other - also has a keymapping utility. xkb seems to have lots of utils and such around it, and is likely more complete than any random window manager's keymapping utils, so I'd look at that first.
KDE 3 is probably the most flexible here; there's a pre-defined keyboard shortcut scheme named "Mac Scheme". You can set it through KControl Control Center > Regional & Accessibility > Keyboard Shortcuts or kcmshell keys and it will have effect on almost all KDE applications immediately. You might miss some of those Emacs-like "Ctrl-*" shortcuts that OS X has, but that aside, it works well (as long as your X modifiers are mapped correctly). And if it's not to your liking, it's easily customizable.
You can also set Control Center > Desktop > Behavior to enable a Mac OS-like menubar; all KDE applications will then share a menubar at the top of the screen instead of being individually attached to each window.
Update 02/03/2020
Kinto has now been rewritten in C for Ubuntu/Debian systems using x11. It also uses json config files, making it easier to manage and extend to other applications than just terminals. The app no longer maps to Super in the Terminal apps, it will now properly map to Ctrl+Shift to create the exact same feel as having a Cmd key.
Please checkout the latest release.
https://github.com/rbreaves/kinto
The main change to allow for the Super = Ctrl+Shift change is in this symbols file.
default partial xkb_symbols "mac_levelssym" {
key <LWIN> {
repeat= no,
type= "ONE_LEVEL",
symbols[Group1]= [ Hyper_L ],
actions[group1]=[ SetMods(modifiers=Shift+Control) ]
};
key <RWIN> {
repeat= no,
type= "ONE_LEVEL",
symbols[Group1]= [ Hyper_R ],
actions[group1]=[ SetMods(modifiers=Shift+Control) ]
};
};
Pjz's answer is correct in saying that an xkb solution would be ideal, sadly few have taken that route, most likely due to the difficulty of learning xkb and it seems many have gone the route of using Xmodmap files which is being deprecated while we are on our way to Wayland.
This answer may be several years too late, but here it is any ways.
Kinto is a tool I recently created that will address this problem and does so by using xkb and by listening to what app you are currently using, as it also changes the keymap while using terminals so the mac like experience can be consistent.
https://github.com/rbreaves/kinto
https://medium.com/#benreaves/kinto-a-mac-inspired-keyboard-mapping-for-linux-58f731817c0
Here's a Gist as well, if you just want to see what is at the heart of it all, it will not alternate your keymap when needed though. The Gist also does not include custom xkb keymap files that setup macOS style cursors/word-wise manipulations that use Cmd and the arrow keys.
https://gist.github.com/rbreaves/f4cf8a991eaeea893999964f5e83eebb
Edit: Posting the contents of the gist as well. I cannot realistically post the contents of Kinto.
# permanent apple keyboard keyswap
echo "options hid_apple swap_opt_cmd=1" | sudo tee -a /etc/modprobe.d/hid_apple.conf
update-initramfs -u -k all
# Temporary & instant apple keyboard keyswap
echo '1' | sudo tee -a /sys/module/hid_apple/parameters/swap_opt_cmd
# Windows and Mac keyboards - GUI (Physical Alt is Ctrl, Physical Super is Alt, Physical Ctrl is Super)
setxkbmap -option;setxkbmap -option altwin:ctrl_alt_win
# Windows and Mac keyboards - Terminal Apps (Physical Alt is Super, Physical Super is Alt, Physical Ctrl is Ctrl)
setxkbmap -option;setxkbmap -option altwin:swap_alt_win
#
# If you want a systemd service and bash script to help toggle between
# GUI and Terminal applications then look at project Kinto.
# https://github.com/rbreaves/kinto
#
# Note: The above may not work for Chromebooks running Linux, please look
# at project Kinto for that.
#
# If anyone would like to contribute to the project then please do!
#
You'll get almost all of the way there if you switch Cmd and Ctrl
xmodmap -e "keycode 63 = Control_L"
That way Cmd will be Control. No other keys will be swapped
Edited: I forgot the "-e"