Sample Header Ad - 728x90

Unix & Linux Stack Exchange

Q&A for users of Linux, FreeBSD and other Unix-like operating systems

Latest Questions

1 votes
2 answers
2529 views
How to switch between applications with one button instead of Super-Tab in a fast way?
I have been using Linux on and off for more than a decade. The one thing that keeps me from completely turning my back on Windows is an Autohotkey-Script I wrote years ago that allows me to quickly switch between application windows with the press of the Pause Button (I suffer from thumb-related RSI...
I have been using Linux on and off for more than a decade. The one thing that keeps me from completely turning my back on Windows is an Autohotkey-Script I wrote years ago that allows me to quickly switch between application windows with the press of the Pause Button (I suffer from thumb-related RSI). It essentially simulates pressing Alt-Tab once. If I want to switch to an arbitrary window different from the last one I can still use Alt-Tab, but for switching between the two most recent windows I can just press Pause. In GNOME I can set Pause to perform the task of switching between applications, but there is a significant delay, it does not just switch to the next window, making it impossible to quickly switch between two application windows. And I can no longer use Alt-Tab to switch to an arbitrary window. **Is there a way to replicate the functionality of this Autohotkey-line on Linux, enabling me to switch between application windows without delay and still maintains the original functionality of Alt-Tab?**
PAUSE::Send, {ALTDOWN}{TAB}{ALTUP}
Preferably a robust way, provided by a Desktop Environment (KDE, GNOME)? I have looked into https://github.com/autokey/autokey , but I don't know if it will be around in a couple of years, whereas Autohotkey has been in use for 20 years now and probably will not go away any time soon. Any suggestions are more than welcome. Thank you very much :).
Alex_289 (11 rep)
Apr 25, 2023, 08:41 AM • Last activity: Apr 14, 2025, 04:04 PM
1 votes
2 answers
368 views
Autokey - Adjusting Screen Brightness with Hotkeys (and sustaining that brightness in Awesome Window Manager)
In [awesome window manager](https://awesomewm.org/), my screen brightness gets reset to 100% each time I'm away from my computer for a few minutes. **How can I get it to sustain the brightness I set prior to these screen-saver/power-management timeouts?** **Background:** Using [autokey](https://en.w...
In [awesome window manager](https://awesomewm.org/) , my screen brightness gets reset to 100% each time I'm away from my computer for a few minutes. **How can I get it to sustain the brightness I set prior to these screen-saver/power-management timeouts?** **Background:** Using [autokey](https://en.wikipedia.org/wiki/AutoKey) , I've created 3 scripts that enable me to adjust my screen's brightness with hotkeys. These scripts use the debian package brightnessctl to accomplish this:
sudo apt install brightnessctl
` For the sake of being helpful to others, I will include these scripts below. **Increase Brightness:**
import os
currentBrightness = system.exec_command("brightnessctl g")
brightnessLevel = str(int(currentBrightness) + 1)
if int(brightnessLevel) > 100:
    brightnessLevel = '100'
if brightnessLevel:
    cmd = "brightnessctl s " + brightnessLevel
    os.system(cmd)
    store.set_global_value("lastBrightness",brightnessLevel)
**Decrease Brightness:**
import os
currentBrightness = system.exec_command("brightnessctl g")
brightnessLevel = str(int(currentBrightness) - 1)
if int(brightnessLevel)  0:
    store.set_global_value("lastBrightness",brightnessLevel)
    cmd = "brightnessctl s " + brightnessLevel
    os.system(cmd)
While these scripts are working perfectly, I do have an issue: When I'm away from my computer for a few minutes, and then come back, my monitor will be in some type of power saving state, where the monitor has been either turned off or displays a black screen. When I wake up the monitor (by hitting a key or moving my mouse) the brightness that I previously set (using brightnessctl), has been changed back to 100% brightness. **How can I sustain my brightness settings thorough these screen-saver/power-saving timeouts?**
Lonnie Best (5415 rep)
Jan 22, 2022, 01:40 PM • Last activity: Oct 30, 2023, 10:53 PM
2 votes
2 answers
1161 views
Autokey - Focus App Window If Running, Launch App If Not
I'm trying to obtain the processID of `pcmanfm` like this: pgrep -f "pcmanfm" When `pcmanfm` is not running, the command above returns nothing (as I expect). However, when I run the command from python, it returns a process ID even when `pcmanfm` is not running: processID = os.system('pgrep -f "pcma...
I'm trying to obtain the processID of pcmanfm like this: pgrep -f "pcmanfm" When pcmanfm is not running, the command above returns nothing (as I expect). However, when I run the command from python, it returns a process ID even when pcmanfm is not running: processID = os.system('pgrep -f "pcmanfm"') Furthermore, if you run the command above multiple times at a python3 prompt, it returns a different processID each time. All the while, pcmanfm has been closed prior to these commands. >>> processID = os.system('pgrep -f "pcmanfm"') 17412 >>> processID = os.system('pgrep -f "pcmanfm"') 17414 >>> processID = os.system('pgrep -f "pcmanfm"') 17416 This is really messing up my ability to launch pcmanfm if it isn't currently running. My script thinks it is running when it isn't. Why is this happening? I'm actually encountering this issue in an Autokey script that I've attempted to write based on this video I watched. Here's my current script: processID = system.exec_command('pgrep -f "pcmanfm" | head -1',True) dialog.info_dialog("info",processID) if (processID): cmd = "wmctrl -lp | grep " + processID + " | awk '{print $1}'" windowID = system.exec_command(cmd,True) # dialog.info_dialog("info",windowID) cmd = "wmctrl -iR " + windowID #dialog.info_dialog("info",cmd) system.exec_command(cmd,False) else: #os.system("pcmanfm /home/user/Downloads") cmd = "/usr/bin/pcmanfm /home/user/Downloads" system.exec_command(cmd,False) The problem is, I keep getting processIDs even when pcmanfm isn't running. The script properly focuses pcmanfm if it is running, but it won't launch it if it isn't. **Update:** I finally got this script to work by taking out -f and replacing it with -nx (from @they 's advice). Also, I added some exception handling to ignore autokey exceptions caused by empty output that's expected. Additionally, I converted it to a (more flexible) function so that it will service a wider variety of commands/applications: import re def focusOrLaunch(launchCommand): appName = re.findall('[^\s/]+(?=\s|$)',launchCommand) processID = None try: processID = system.exec_command('pgrep -nx "' + appName + '"',True) except Exception as e: #dialog.info_dialog("ERROR",str(e)) pass #dialog.info_dialog("info",processID) if (processID): cmd = "wmctrl -lp | grep " + processID + " | awk '{print $1}'" windowID = system.exec_command(cmd,True) # dialog.info_dialog("info",windowID) cmd = "wmctrl -iR " + windowID #dialog.info_dialog("info",cmd) system.exec_command(cmd,False) else: system.exec_command(launchCommand,False) cmd = "/usr/bin/pcmanfm ~/Downloads" focusOrLaunch(cmd)
Lonnie Best (5415 rep)
Jan 18, 2022, 03:57 PM • Last activity: Jan 22, 2022, 12:14 AM
Showing page 1 of 3 total questions