How do I change power-off-button action without Gnome? - linux

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.

Related

Ubuntu, lock screen but do not screensave

When I do not use my graphical session anymore, the screensaver automatically lock it and power off the screen to save energy.
I want it to keep locking my session but not to power off the screen, is it possible ?
I use Ubuntu 18.04 with default gnome display manager.
Thank you,
Matias
As described in this thread on ubuntu forums it looks like this is part of the gnome-screensaver-command and there is no easy way to disable it. Try replacing the default screensaver with another one, like xscreensaver.
Hint: when you manually lock your screen, just hold the buttons a second longer and the screen won't turn off.

kde 'window shortcuts' are temporary

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

running x11 on cygwin, all terminals stuck at one corner

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

alt-tab like functionality when using terminal?

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.

system wide keyboard hook on X under linux

What would be the best approach to install a keyboard hook on Linux (X-windows) in order to trigger some application when some key-combo is pressed?? Is there a way to do this regardless of which window manager is running? The idea is to have an application being called ( or brought to foreground ) when some key is pressed in a way similar that Google Desktop does to Ctrl-Ctrl.
XGrabKey on the root window is how xbindkey does it. Be careful about having some alternative method of killing the grab though, it's very annoying to have to go somewhere to ssh into your own box just to kill that process... And that's why, if it was me, xbindkeys+"echo 'moo' > /tmp/moo-fifo" would be the way to do it. That way, you could also control it in any number of other ways you haven't thought of yet.

Resources