I'm running the KDE desktop, and I'd like to associate hotkeys with a set of windows and use those hotkeys to activate those windows from anywhere. Ideally, this would work like in Windows - where the key launches the app the first time you press it, and thereafter just brings it to the front. But I don't think that's possible in KDE (why not???).
Anyway, the kwin window menu has a "More Actions/Window Shortcut" option that does let you set a key combination that will bring that window to the front. Except that it only works for the current session. Is there no way to make that association permanent?
In my normal Windows workspace, I have 2 PuTty sessions logged on to a unix host under different user ids. Each of these has an associated hotkey. In addition, I have the app I work in (a browser of sorts) with its own hotkey, and a programming editor with its own key. I am constantly switching between these 4 windows, and I do it all with keystrokes. And I use the same keystrokes to start those sessions up when I first need them. It's great - the only Windows feature that I seriously miss when running Linux. How can I come closest to having that in KDE? Or some other Linux desktop?
Well, I tried xdotool, and combined in a script and attached to a KDE custom shortcut, it actually works. Launches the app if xdotool doesn't find it, and activates the window if it does. Painful, but it does work. The app in question is WIN32 code - hence launching it via wine.
Here's the script:
#!/bin/bash
pid=`xdotool search --name Medialine`
if [ "$pid" == "" ]; then
wine /home/rob/wem.exe&
else
xdotool windowactivate $pid
fi
Related
On modern Fedora Linux installations, pressing the computer's "power off" button does not actually shut it down, but rather hibernates it, which is very convenient.
However, this is only true if I run the default Gnome window manager. If I use a different window manager (my favorite is the old-school ctwm), this doesn't happen - the power-off button shuts down the system instead of hibernating.
My question is: How can I tell my system (I don't mind a little coding, and it doesn't need to be inside ctwm) to do something else - and not a shutdown - when the poweroff button is pressed. Without Gnome.
I did a little digging, and it appears that I have "upowerd" running. However, it is running just the same when ctwm and Gnome are the current window manager, so Gnome must somehow be telling upowerd not to power-off the computer and instead either do something else (like hibernate) or send Gnome that the event happened. But I couldn't find any documentation on how that's done, or how I can do something similar without Gnome.
Using xfce4-keyboard-settings, I have SuperL keybound to start rofi using rofi -show drun, but this prevents me from using SuperL in combination with any other key combinations, such as Super + L to lock the screen. rofi is hijacking the show immediately.
I've tried prepending a sleep to rofi, ie. sh -c "sleep 1 && rofi -show drun", which correctly sleeps and even lets me use Super + L to lock the screen, but then rofi loads over the top and starts to interact weirdly (read: undesirably) with the lock screen.
Is there a way that I can have both keyboard shortcuts work as desired without interfering with eachother?
BTW, the lock screen I'm using is i3lock-fancy.
I solved this following AndreLDM's advice.
I installed xcape, and added xcape -e 'Super_L=Control_L|Escape' to ~/.config/openbox/autostart and bound the keyboard shortcut Ctrl+Esc to run rofi. I was then able to keybind Super+L to i3lock-fancy and have both keyboard shortcuts work as I intended. Pressing Super by itself presents my rofi drun menu, and Super+L locks the screen.
I was after the exact same functionality on Manjaro XFCE. I found that even though the whisker menu popup was bound to <Alt + F1>, it still popped up when I pressed < SuperL >. So instead of binding rofi to I bound it to <Alt + F1>.
With that I was able to start rofi with < SuperL > and also use it in combination with other keys.
You may need to install this package.
ksuperkey allows you to open the application launcher in desktop
environments such as KDE Plasma and Xfce using the Super key (also
known as "Meta" or "the Windows key"). If you hold down the Super key
it will still act as a modifier key, allowing you to use it for other
keyboard shortcuts.
I am trying to run x11 on cygwin, mainly to run xfig utility, and I am facing a problem.
When I run xinit to start x11, I get a big popup window with one terminal open. But I am unable to open any other terminals in it. To be more specific, when I run "xterm &" in it, a new terminal opens up but it sits on top of the old terminal, and there is no way I can move this window, so the old terminal is as good as useless to me, till I kill the new terminal.
I also tried running "xwin". There a big window popped up, but it does not contain any terminal, and I cant open any terminal, whether by left or right clicking.
I also tried running "startx". A big window opens up but gets killed automatically after a few seconds.
How can I use x11 effectively on cygwin? As of now, I can use with "xinit", but with only one terminal.
The proper mode to start the Xserver on cygwin is to use starxwin.
From its manual:
The startxwin script is a front end to xinit(1) that provides a
some what nicer user interface for running a single session of the X Window
System in multiwindow mode. It is often run with no arguments.
To move windows around, you need to have a window manager running. You can start this either from the xterm, by passing the name of the window manager as an argument to startx, or by starting it from your X11 startup configuration (memory says that would be ".xinitrc" in your home directory on most unix boxes, but I am not sure if that's true on Windows using Cygwin). The .xinitrc file is "just" a shell-script, with the end of the script indicating "X should shut the server down now" (see example at the end).
There are many possible window managers, including fvwm2 (which according to your comment, you managed to find on your own). A full list of X11 window managers is probably too long to fit in this answer (there are many, there are new ones popping up, and old ones going out of maintenance on an ongoing basis). Some of the not entirely uncommon ones are fvwm2 (already mentioned), cinnamon, twm, ctwm, ratpoison, ... For a more up-to-date list, ask your favourite search engine for "list of X11 window managers".
Example .xinitrc file:
# This is an example .xinitrc file, starting first an xterm,
# then a window manager. As the X server terminates when this script
# does, we start the X terminal in the background, but the window
# manager in the foreground, so that "WM exists" signals "X server shuts down"
xterm &
fvwm2
When working in GUI we do alt-tab (or cmd-tab in mac) to switch between multiple programs, for example I am writing a text file in a text editor and then I do alt-tab to switch to already running browser to google up something then I alt-tab again to come back to keep editing.
How do you perform such "switch between" programs in command line interface - for example working with a ssh command line shell?
EDIT: I forgot to mention it, I am using ssh to connect to my university's server, and they don't have screen & tmux installed, and my account have no right to install any new apps... Is there any built-in functionality to perform this task, or any work around? For exmaple can I "minimize" running proggram and come back to regular shell interface, do some work, then display the "minimized" process again?
Another workaround: use the shell's job control, eg if you're editing a file, CTRL-z pauses the editor and brings you back to the shell, where you can compile, see manpages, browse the web or whatever -- and of course you can background the browser or anything else.
Screen command offers the ability to detach a long running process (or program, or shell-script) from a session and then attach it back at a later time.
As a crude workaround, run multiple terminal windows on your computer, and alt-tab between them.
Incidentally, at the Linux console, you can switch virtual terminals with ctrl+alt+F for at least F1 through F6, commonly F8 or more (depends on how the distro sets them up). Not your case, I know, but in case future visitors should benefit.
If you are comfortable in Emacs, it allows you to run multiple independent ansi-term buffers.
You can also use "GNU screen" to emulate multiple terminals in one terminal.
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"