I would like to inquire if there is a program in Linux that we can use to assign new keyboard shortcut per application. For example, if I'm in FeatherPad I would like to assign Super+S to save. If I'm in terminal, I would like to use Super+V to paste.
Or a program that cab map/assign new shortcut and translate that to an existing shortcut. If in terminal I can paste with Shift+Insert then I would like to map Super+V to Shift+Insert
The closest analogy would be a program like Autohotkey in Microsoft Windows. How do I do this in Linux Desktop environment regardless it is Gnome2/Unity/XFCE etc. ?
There used to be a way to do this called "custom accelerators" or "editable accelerators". It used to be supported in GNOME 2 and XFCE (maybe in others). But since the move to gtk3, this functionality seems to have been removed in GTK-based desktop environments.
In KDE/Plasma, you can use System Settings -> Shortcuts -> Global Shortcuts and then the plus symbol to add specific shortcuts that only apply to certain applications, but unfortunately, not all applications support it.
In FeatherPad itself, there should be Options -> Preferences -> Shortcuts, but I've had no luck getting it to register any shortcut consisting of just Super and a key.
I'm unfamiliar with Autohotkey but it seems that AutoKey is sometimes mentioned as an alternative on Linux?
Related
I know how to set a keyboard command shortcut, that's easy, I just go to Applications > Settings > Keyboard and then click the Application Shortcuts tab within my Manjaro Linux system and set whatever command to whatever shortcut.
But how can I make it run that command on a selected file or selection of files?
Is there something I can change or add to the command to make it run on the file or files currently selected within my XFCE desktop environment?
Thanks!
Your approach would require to correlate your mouse position to your desktop and file-manager. Then you would need to have knowledge of the internal state. You then would need to display some GUI. This way of thinking in regards of programing is seriously wrong.
What you are looking for are context menu actions. So keep it that way.
You have files on your desktop or in the file-manager and can call user defined actions on one or more files. I think XFCE had something like Thunar. You may use caja wit caja --no-desktop and create some actions with caja-actions-config-tool. Gnome still has it, if you prefer Nautilus.
I have Linux (Backtrack5) running as guest operating system in IOS.
There seems to be some problems with certain keys, I can't type the # sign.. instead, it gives 2 (in superscript).
I have tried hex (%40) but it won't compile.
I have reinstalled it with another keyboard layouts but problem reproduces.
Is there a file where i can reconfigure certain keys?
I am afraid I may sound trivial, but maybe this is your case.It might be that the keymap your system loads by default does not match the one your physical keyboard actually has.
You can change the keyboard layout you're using with setxkbmap it Return typed in a console in your graphical environment (X11), be it under KDE, GNOME, or what you have. With that command you would use an Italian keyboard layout, it looks like the two-letter code for a Danish one is da.
If you're not working with a graphical environment you can set your keyboard layout with loadkeys it Return
OSX allows user to add custom keyboard shortcuts for menu items. For instance you can define a custom keyboard shortcut for "Copy" and it will work for every application that has a menu item called Copy.
Is there a way to do this for GTK and/or KDE applications?
For KDE applications, it is possible for common keyboard shortcuts. To do this, open systemsettings and navigate to Standard Keyboard Shortcuts.
For example, here I change the shortcut for "activate next tab" to Ctrl-Tab (for consistency with Firefox):
This changes the shortcut in most tabbed KDE applications as well as tabbed dialog boxes. You can specify up to 2 alternative shortcuts for each action.
However, this only works for common shortcuts; you can't globally specify shortcuts for arbitrary menu-item captions.
I don't think GNOME applications have any such feature. You have to change the shortcuts individually (for each application). (Generally KDE is more customizable.)
Is there a way to set an absolute keyboard shortcut for an arbitrary menu item name that will be honored by any GTK+ application?
No.
Can you set a different global shortcut for Cut/Copy/Paste?
I suspect so. I didn't do the reading, but here's two promising links: making keyboard shortcuts in linux as uniform as the mac and change default/preference keyboard shortcuts like copy & paste
You can of course modify GTK+ applications to tweak their shortcuts. In the case of a GTK+ application whose GUI was designed with Glade, e.g. virt-manager, this could be ridiculously trivial.
I suggest you to take a look at xbindkeys and xdotool. Those are the automation tools which can help you to simulate certain keystrokes with customized shortcut.
By this means, though you don't really modify the original shortcuts, but you can still make your desired key combinations functional.
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 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