Code Monkey home page Code Monkey logo

run-or-raise's Introduction

Run-or-raise

https://extensions.gnome.org/extension/1336/run-or-raise/

About project

I assume the run-or-raise style as the most efficient way of handling windows. No more searching for your favourite program in a long menu, no more clicking on the icons. If the program already runs it will get the focus, else we launch it.

Several years ago, OS creators finally realized that efficiency and let the users run-or-raise programs on the taskbar or dock by Super+number shortcuts. But what if you use more programs than nine? What if you do not want the unnecessary taskbar to occupy the precious place on the screen?

With the emergence of Wayland over X.org, we can't reliably use good old xbindkeys and jumpapp to master shortcuts. Here is a gnome-shell extension that let you migrate your favourite shortcuts to the shortcuts.conf file.

Contents

Installation

  • through GNOME3 extensions (official, easy, not always up to date)

OR

  • clone this repo to /home/$USER/.local/share/gnome-shell/extensions/[email protected]
  • reload extensions (e.g. log out in wayland - details here)
  • enable run-or-raise in gnome-extensions-app panel
  • in the extension preferences, you may edit shortcuts.conf file to use your own shortcuts
  • you may load new shortcuts without restarting, just change the file shortcuts.conf, and disable and enable.

Configuration

On the first run, ~/.config/run-or-raise/shortcuts.conf gets created from shortcuts.default if not exists. There you define your own shortcuts.

Note that if an argument should contain a comma, use double quotes around.

<Super>i,"/usr/bin/cmd comma, needed",,application_title

How to create a shortcut

When you trigger a shortcut it lets you cycle amongst open instances of the application or if not found, launches a new instance. The file consists of shortcuts in the following form:

shortcut[ shortcut][:mode],command,[wm_class],[title]

Shortcut

Shortcut consists of an arbitrary number of modifiers (angle brackets) and a character, like <Shift>a, <Shift><Super>a, simple a or <Super>slash. Character might be either a keysym (a, acute) or a keycode in the hex format, ex: letter a with the keycode 38 is noted 0x26.

For custom shortcuts, I recommended using mostly combinations containing the modifier <Super> as this normally indicates global shortcuts. In the opposition to <Shift> which is semantically reserved for letter case a/A, <Alt> for underlined letters and <Ctrl> for various application-defined actions.

Possible modifiers:

  • basic
    • <Shift>, <Alt>, <Meta>, <Ctrl> (<Primary>), <Super> known as Win, <Hyper>
    • you may not have all of them on your keyboard by default
    • <ISO_Level5_Shift> (I really recommend mapping this modifier instead of Caps Lock)
  • mods
    • <Mod1>, <Mod2>, <Mod3>, <Mod4>, <Mod5>
    • consult xmodmap to see the overview of the keys that are mapped to mods
    • consult xev/wev to determine key symbols you have mapped
    • ex: if the key Alt Gr corresponds with the key symbol <ISO_Level3_Shift> that is bound to mod5, you would use <Mod5> to create its shortcuts
    • ex: imagine you have both <Super> and <Hyper> on mod4. You bind them all by <Super>i, <Hyper>i, <Mod4>i shortcuts. As they are the same on the internal Gnome-level, only the first shortcut grabs the accelerator, the latter defined will not work. For more information, consult Gnome/Mutter/core/meta-accel-parse.c source code.
  • non-standard locks: Not proper Gnome shortcuts implemented by the extension allow to control the accelerators being listened to depending on the keyboard locks state.
    • <Num_Lock>, <Num_Lock_OFF>
    • <Caps_Lock>, <Caps_Lock_OFF>
    • <Scroll_Lock>, <Scroll_Lock_OFF> (Scroll_Lock might not be available in Wayland session, hence might be removed in the future)

Multiple actions may be registered to the same shortcut (a shortcut appears on multiple lines). They get lauched sequentionally.

<Super>e,notify-send appears first
<Super>e,notify-send appears second

Layered shortcuts are possible. After the shortcut is hit, you may specify one or more shortcuts to be hit in order to trigger the action.

<Super>e a,notify-send Launched a
<Super>e b,notify-send Launched b
<Super>e c d,notify-send Launched cd
<Super>e c e,notify-send Launched ce
<Super>g,notify-send Launched "<Super>g"
<Super>e <Super>g,notify-send Launched "<Super>e and then <Super>g"
<Super>e <Super>e e,notify-send Launched "<Super>e e"

If you need to discover a keysym (or at xkbcommon.org), I recommend the xev/wev program again.

<Super>grave,notify-send "Using backtick in the shortcut: `"

When in trouble, use keycode in hex form instead of a keysym. In this example, we recognize 49 is the keycode of the backtick (31 in hex).

$ wev  # type backtick key
[14:     wl_keyboard] key: serial: 23425; time: 8592750; key: 49; state: 0 (released)     sym: grave        (96), utf8: ''

Hence the hex form is 0x31:

<Super>0x31,notify-send "Using backtick keycode in the shortcut: `"

Action: command, wm_class and title

  • command can be either:
    • a command line instruction to be spawned in a new process
    • the name of an application's .desktop file to be activated
  • wm_class and title arguments are optional and case-sensitive
  • if neither wm_class nor title is set, lower-cased command is compared with lower-cased windows' wm_classes and titles

Understanding title and wm_class

The title is shown in the header area. Since the title tends to be dynamically changed by the application, you can use wm_class which compares to both parts (both WM_CLASS_NAME and WM_CLASS_INSTANCE) of this window property.

How to know the wm_class? Just use the xprop program and filter the WM_CLASS line:

$ xprop
# hit the mail window with the mouse cursor and get:
WM_CLASS(STRING) = "mail.google.com__mail_u_0", "Google-chrome"

The first string mail.google.com__mail_u_0 is more specific WM_CLASS_INSTANCE, the second Google-chrome is more stable WM_CLASS_NAME.

Alternatively, you can use the looking glass tool (at least on Ubuntu 17.10+) by launching Alt+f2 / lg / "Windows" tab. There, you see WM_CLASS_NAME listed as wmclass. To get the WM_CLASS_INSTANCE, click on a window title / button "Insert" / go back to the "Evaluator" tab and refer the window via the inserted value r like: r(0).get_wm_class_instance(). I found no easier solution for the moment.

Comparison of different matching approaches

Following shortcut will firstly launch mail window in an application mode. Later on, it will cycle all windows that have mail.google.com in the wm_class. (Which is what we want here.)

<Super>e,/opt/google/chrome/google-chrome --app=https://mail.google.com/mail/u/0,mail.google.com,

In an opposite manner, this would cycle all Chrome windows. (Which is not what we want.)

<Super>e,/opt/google/chrome/google-chrome --app=https://mail.google.com/mail/u/0,Google-chrome,

And finally, using the title part rather than the wm_class part, this would cycle all windows that have Gmail in the title. On one side this would include windows just mentioning Gmail (bad). On the other side when somebody writes you to the chat, the window title changes and the shortcut would open another Gmail instance (even worse).

<Super>e,/opt/google/chrome/google-chrome --app=https://mail.google.com/mail/u/0,,Gmail

Modes

Modes are special instructions that let you change the triggered behaviour. Some of them can be turned on globally in the extension preferences (so you do not have to specify them for every single shortcut if you need them everywhere).

You can combine multiple modes by appending a colon. On the first hit, we register a window. On the second, we raise it while bringing to the active workspace.

<Super>i:raise-or-register:move-window-to-active-workspace

isolate-workspace

Switch windows on the active workspace only

# cycles Firefox instances in the current workspace
<Super>KP_1:isolate-workspace,firefox,

minimize-when-unfocused

Minimizes your target when unfocusing

switch-back-when-focused

Switch back to the previous window when focused. If a shortcut has no but a single window to cycle, it focuses last used window instead of doing nothing.

move-window-to-active-workspace

Move window to current workspace before focusing. If the window is on a different workspace, moves the window to the workspace you're currently viewing.

center-mouse-to-focused-window

Moves mouse to the center of the newly focused window (unless cursor is not in the window area already).

always-run

Both runs the command and raises a window

# Runs a command whether a window with wm_class 'kitty' is already open or not
<Super>t:always-run,my_tmux_script.sh,kitty

run-only

Since it is very convenient to use a single file for all of your shortcuts (backup, migration to another system...), you can define standard shortcuts as well. These commands just get launched whenever the keys are hit and never raises a window. The keyword is implicit if no superfluous commas are noted in the line: shortcut,command

# this line will launch the notify-send command.
<Super>y,notify-send Hello world

# this line WILL raise a Firefox window or launches a command (note a trailing comma)
<Super>f,firefox,

# these equivalent lines will always launch a new Firefox instance, never raising a window
<Super>f,firefox
<Super>f:run-only,firefox,

register(0)

Register the current window dynamically to be re-raised by using raise mode with the same number in the argument

<Super><Ctrl>KP_0:register(1)
<Super>KP_0:raise(1)
<Super><Ctrl>KP_Delete:register(2)
<Super>KP_Delete:raise(2)

raise(0)

Raise the windows previously registered by the register keyword

raise-or-register

If nothing registered yet, register the current window. Next time raise it unless the window is closed. In the example, we set Super+i and Super+o to bind a window each.

<Super>i:raise-or-register
<Super>o:raise-or-register

raise-or-register(0)

If nothing has been registered yet, register the current window. Next time, raise it, unless the window is closed or has been remapped with register(the same number). Thus, it is a combination of register, raise, and raise-or-register.

verbose

Popups debug details via notify-send. (Normally it seems launched commands pipe the output to the /var/log/syslog.)

Examples

This line cycles any firefox window (matched by "firefox" in the window title) OR if not found, launches a new firefox instance:

<Super>f,firefox,,

This line starts gnome-terminal using it's .desktop file:

<Super>f,org.gnome.Terminal.desktop,,

This line cycles any open gnome-terminal OR if not found, launches a new one.

<Super>r,gnome-terminal,,

If you want to be sure that your browser won't be focused when you're on the page having "gnome-terminal" in the title, you may want to match running application by wm_class = Gnome-terminal on Ubuntu 17.10 or by wm_class = gnome-terminal-server on Arch... just check yourself by Alt+F2/lg/Windows everytime wm_class is needed.

<Super>r,gnome-terminal,Gnome-terminal,

You may use regular expressions in title or wm_class. Just put the expression between slashes. E.g. to jump to pidgin conversation window you may use this line (that mean any windows of wm_class Pidgin, not containing the title Buddy List)"

<Super>KP_1,pidgin,Pidgin,/^((?!Buddy List).)*$/

To match Google-chrome and not Google-chrome-beta, help yourself with $ sign to mark the end of matched text.

<Super>KP_3,gtk-launch google-chrome.desktop,/Google-chrome$/,
<Super><Shift>KP_3,gtk-launch google-chrome-beta.desktop,Google-chrome-beta,

Another occasion you'd use regulars would be the case when you'd like to have multiple applications on single keystroke. In the following example, shortcut Super+Ctrl+(Numpad)4 focuses an IDE editor, either NetBeans or PyCharm. Because I'm mainly using NetBeans but for Python language I prefer PyCharm, I was wrong too often till I set single keystroke for both. (However, when no IDE is open, for launching NetBeans I use numpad and for PyCharm the 4 on the 4th row of keyboard.)

<Super><Ctrl>4,/opt/pycharm-community-2017.2.4/bin/pycharm.sh,,/(NetBeans IDE|PyCharm)/
<Super><Ctrl>KP_4,/opt/netbeans/bin/netbeans,,/(NetBeans IDE|PyCharm)/

To run a command as a sudo, try simple pkexec program that raises the password dialogue. For a repetitive task, familiarise yourself with the system sudoers file.

<Super>r,bash -c 'notify-send "Root folder" "`pkexec ls /root/`"'

Tips

  • For the examples, see shortcuts.default file.
  • You may change the configuration file on the fly. Just disable & enable the extension, shortcuts load again from scratch. Ex: gnome-extensions disable [email protected] && gnome-extensions enable [email protected]
  • In the case of segfault, check no conflicting key binding is present, then submit an issue.

Barebones “GNOME Shell native” alternative

Note that GNOME Shell supports a basic run-or-raise workflow out of the box! To enjoy a basic run-or-raise with no extension:

  1. Pin your favorite apps to the Dash (ActivitiesRight click on open app → Pin to Dash).
  2. Don’t let the default <Super+number> bindings cause you a left thumb RSI! To re-bind them, set dconf values org.gnome.shell.keybindings / switch-to-application-N to your desired keyboard shortcut (where N is 1..9), replacing / adding to the default binding.
  3. Never re-order your pinned apps.

Caveats: Limited to 9 apps; no wmclass regex support; limited to static StartupWMClass in XDG .desktop files; no modes.

Developer guide

How to implement a new mode?

  • create new static keyword in the Mode class in the mode.js file
  • create the same in gschema.xml if the keyword should be available globally for all the shortcuts and run make compile
  • put the logics into Action.trigger method, by checking if the settings is on (either locally per shortcut or globally) by this.mode.get(Mode.KEYWORD)
  • document here in the README.md
  • put a description into CHANGELOG.md file
  • raise a version in metadata.json
  • create a pull request with (preferably) a single commit

Debugging

When tired of logging out to refresh the code, launch a new wayland session ex by:

(sleep 1 && gnome-extensions disable [email protected] & ) && dbus-run-session -- gnome-shell --nested --wayland && gnome-extensions enable [email protected]

What does this command do? Note that the extension must be running in the main session in order to be started in the nested session too. So after a second, we disable it in the main session to not interfere with the nested instance of the extension: They share the same shortcuts and the main would prevail. When the nested session is over, enable it in the main session again.

run-or-raise's People

Contributors

andrewkvalheim avatar coddingtonbear avatar daandemeyer avatar e3rd avatar markolenik avatar poxar avatar romixch avatar ronjouch avatar ryantm avatar teur avatar xalt7x avatar zba avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

run-or-raise's Issues

Extension is incompatible with GNOME 40

I'm unable to install the extension via extensions.gnome.org. The last compatible version appears to be 3.38.1. Can this extension please be updated to support the latest GNOME release?

Feature request: Add the ability for Run or Raise to be trigger by terminal scripts

Run or raise is one of the first extensions or apps that I've seen in gnome-wayland that gives the user the ability to raise windows. I can't even get gedit to raise when new tabs are opened at the moment, so the fact that an extension has the feature is pretty amazing.

I was wondering if it would be possible to add additional ways of triggering the run or raise behavior than hotkeys. It would be nice if we can set it up so that it can be trigger by scripts. For example, the extension can maybe poll for the existence of a certain file that the script can create and inside the file, there would be a raise command of some sort that the extension would execute.

slashable commas?

For chromium app window, I'd like to specify window size flag. Nevertheless, that uses commas:
--window-size=300,200,,Time tracker

Would we:

  • make somehow comma slashable
  • put argument into "s
  • look how other projects treat this

Feature request: Highlighting window that will be focused after releasing keybind

GNOME's "Switch windows directly" switcher (Alt-Esc by default) shows an inner border on the window that will end up being focused/raised until you release the modifier key. I would like something similar but I don't have the knowledge to know how to do this. Can you implement this feature into the extension or point me to a utility I could use in bash scripts to reproduce the effect?

2020-04-19-145147_2560x1080_scrot

"unable to grab accelerator" for slash and backslash

Setting commands for slash and backslash doesn't seem to work (<Super><Alt>/ and <Super><Alt>\). When restarting the extension, I get a notification saying "unable to grab accelerator /). Is this expected?

Is there a list of characters that are supported?

Thanks for this extension!

Minimize on Unfocus broken?

First, praise:

I am on Pop!_OS 21.04 on Wayland, making use of the tiling feature, and am absolutely overjoyed I have found this extension! I was looking for a "drop down filemanager" that I can use to overlay my tiled windows---thank you for providing that!

Second, the issue:

I would like my called window to minimize when it looses focus. This is sounds like what is implemented by @coddingtonbear in #24. But I don't see the behavior I expected:

<Shift>F5:minimize-when-unfocused,nemo,nemo,

will make the shortcut run Nemo/focus it if not focused, and minimize it if I press it again, but if I shift the focus from the called window---e.g., by mouse-click or shortcut---the called window does not minimize.

Was the window supposed to minimize when thus loosing focus, or is the described the intended behavior?

window class regex

I want a shortcut to launch LibreOffice Writer and another to launch any other LibreOffice app except Writer.

Flatpak apps not running

When i try to run my flatpak apps i get the error: execution of "pidgin" failed: command not found

the command i made was: 1,flatpak run md.obsidian.Obsidian,

Shortcut to run or raise google-chrome but not to raise google-chrome --app=https://mail.google.com/mail/u/0

Hi thanks for creating such a great extension.

I have one shortcut to open discord in brave:

<Super>d,brave-browser --profile-directory=Default --app=https://discord.com/channels/865432401270145054/1083781888163979275,,Discord

and another shortcut to open brave:
<Super>w,brave-browser,Brave-browser,

However when discord is open, and I press Super+w, which I intend to open brave, it also sometimes opens discord (i.e. it cycles though all my brave windows including my discord window, if one is open, due to it using brave).

Is there a way that I can modify either of the above shortcuts such that pressing super+w will only ever open standard brave windows and never the discord app window?

Perhaps a solution would involve allowing for a negative filter to be added to the brave-browser shortcut configuration so that it excludes windows with discord.com in one of the WM_CLASS strings. This would solve the problem for me as the discord brave window has the following WM_CLASS strings according to xprop:

WM_CLASS(STRING) = "discord.com__channels_865432401270145054_1083781888163979275", "Brave-browser"

An alternative solution would be to filter on WM_WINDOW_ROLE.
For normal brave windows WM_WINDOW_ROLE(STRING) = "browser" whereas for discord windows WM_WINDOW_ROLE(STRING) = "pop-up"

So adding a requirement that WM_WINDOW_ROLE=browser for the brave command would presumably result in it excluding discord windows, as desired.

many thx!

request: raise-or-register with index

I started from

<Super><Shift>1:raise-or-register
<Super><Shift>2:raise-or-register

but realized sometimes i want to change which window I want to register, but without closing the previously registerex one.
So I found out about this:

<Super><Shift>1:raise(1)
<Super><Shift>2:raise(2)
<Ctrl><Super><Shift>1:register(1)
<Ctrl><Super><Shift>2:register(2)

but I'd actually love have:

raise-or-register(1)

so that I can use the same keybinding for the first registration, but in case I need to change, can use the CTRL+ modifier to overwrite.

Mouse shortcuts

Hello and thank you for this extension.

Currently, I use xbindkeys with X.Org in this form and it works well using a shortcuts linked to one of my mouse buttons. As you mentioned, Wayland arrives and I would like to find the same way to use my mouse with X.Org

An excerpt from my .xbindkeysrc file:

Open gnome-terminal with mouse button 10

"Gnome-terminal"
b: 10

How to get the same result with your extension using only the mouse buttons?

Thank you.

Feature request - Run, Raise or lower

As per title:

  • If not running, run

  • if running, bring to front.

  • If window is focused, lower.

I have a script that can do this for X, but as it extensively uses wmctrl & xdotool it will not function under Wayland.

"Cannot get system pointer"

Every time I switch windows using run-or-raise, the switch works, but I get a notification saying:

Cannot get system pointer, please report with `gnome-shell --version`

Here's the output of gnome-shell --version:

GNOME Shell 42.0

Error: TypeError: window_title[titleFn] is not a function

After installing what I think is an update to this extension, I am experiencing the following issues:

  • switching to an application now incurs a 1 second delay, if successful
  • however with some applications that are not successful, I incur this error when attempting to switch to them:
    TypeError: window_title[titleFn] is not a function
    image

So far Brave is the only application which causes this error when attempting to switch to it. Interestingly though, Brave opens successfully the first time the shortcut is used (i.e. if it is not already running), however fails to be refocused upon future attempts to use the associated shortcut, due to the above mentioned error.

Un-focusing also does not seem to be working for any application, even those which raise or run is able to focus after a multi-second delay. However I do not encounter any error message when attempting, unsuccessfully, to un-focus a window which is currently focused. This used to work perfectly until what seems to be a recent update.

Un-focusing does however trigger the TypeError: window_title[titleFn] is not a function error message when attempting to un-focus an application for which focusing also fails, such as brave.
I have also noticed that re-focusing some applications causes them to be opened from scratch, despite the fact that they previously used to re-focus successfully without being re-executed. Specifically, this occurs for Obsidian.

These are config options:
image

And my settings file:

# Here you list all the shortcuts.
#
# The shortcuts may be defined in two ways:
#
# 1. Run-or-raise form: shortcut,command,[wm_class],[title]
#        * `wm_class` and `title` are optional and case sensitive
#        * if none is set, lowercased launch `command` is compared with lowercased windows wm_classes and titles
#
# 2. Run only form: shortcut,command
#
#
# In fact, full form is `shortcut[ char][:mode],command,[wm_class],[title]`
# while `char` allows you to use layered shortcuts and `mode` to further specify circumstances.
#
# =================
# Run or raise form
# =================
#
#
# This line cycles any firefox window (matched by "firefox" in the window title) OR if not found, launches new firefox instance.
#<Super>f,firefox,,
# This line cycles any open gnome-terminal (matched by wm_class = Gnome-terminal on Ubuntu 17.10) OR if not found, launches new one.
# If you're using Arch, you may want to match by wm_class = gnome-terminal-server , just check yourself by Alt+F2/lg/Windows
#<Super>r,gnome-terminal,Gnome-terminal,


# You may use regular expression in title or wm_class.
# Just put the regular expression between slashes.
# E.g. to jump to pidgin conversation window you may use this line
# (that means any windows of wm_class Pidgin, not containing the title Buddy List)"
#<Super>KP_1,pidgin,Pidgin,/^((?!Buddy List).)*$/


# Run only form
# =============
#
# This line will launch the `notify-send` command.
#<Super>y,notify-send Hello world

# This layered shortcut will output the text only when you write `hello` after hitting <Super>e.
#<Super>e h e l l o,notify-send Layered hello

# This layered shortcut will not interfere with the shorcut above that is launching a terminal.
#<Super>e <Super>r,notify-send Layered 'Terminal was not launched.'

# Blank lines are allowed. Line starting with "#" means a comment.
# Now delete these shortcuts and put here yours.
# How to know wm_class? Using xprop or the looking glass tool, see README.md



# Converted Shortcuts

# Opens Nautilus file manager
<Super>n,nautilus,org.gnome.Nautilus,

# Opens Gnome System Monitor
<Super>m,gnome-system-monitor,gnome-system-monitor,

# Opens Gnome Control Center (Settings)
<Super>p,gnome-control-center,org.gnome.Settings,

# Opens KeePassXC password manager
<Super>k,keepassxc,org.keepassxc.KeePassXC,

# Opens Signal desktop application
<Super>s,flatpak run org.signal.Signal,Signal,

# Opens Discord in Brave browser
<Super>d,brave-browser --profile-directory=Default --app=https://discord.com/channels/865432401270145054/1083781888163979275,,Discord

# Opens Brave browser
<Super>w,brave-browser,Brave-browser,Brave

# Opens Telegram desktop application
<Super>t,/opt/Telegram/Telegram,org.telegram.desktop._3e485da34fc040f9218e3891ecde1e6c,

# Opens Obsidian note-taking app
<Super>z,flatpak run md.obsidian.Obsidian,obsidian,

# Opens Visual Studio Code
<Super>v,code,Code,

# Opens ProtonMail in Brave browser
<Super>e,brave-browser --profile-directory=Default --app=https://mail.proton.me/u/1/inbox,,Proton Mail

# Opens Gnome Terminal
<Super>x,gnome-terminal,gnome-terminal-server,

# Opens Gnome Text Editor
<Super>g,gnome-terminal -- bash -c 'nvim; exec bash',,Terminal

# Opens Gnome Calculator
<Super>c,gnome-calculator,org.gnome.Calculator,

# Pause/play audio
<Ctrl><Super>p,playerctl play-pause

# toggle audio output
<Ctrl><Super>a,python3 /home/pimania/dev/manageAudio/switchAudioSink.py

# update blog
<Ctrl><Super>b,/home/pimania/dev/autoBlogPost/run.sh

#vim hints
<Ctrl><Super>v,brave-browser https://vimsheet.com/

Many thx!

Launching .desktop Applications Results in "Command not found" Notification

I use GNOME Shell 41.3 on Debian.

Here are some example configuration directives that do not work:

<Alt>F6,brave-browser.desktop,,
<Alt>F8,jetbrains-studio.desktop,,
<Alt>F9,emacs.desktop,,

For some unknown reason the Brave browser shortcut flickers the currently focused application (blue border), and nothing else happens. The other two shortcuts result in a notification as described in the issue title.

When I use lg with the corresponding command, e. g. Shell.AppSystem.get_default().lookup_app("brave-browser.desktop") the id's for all three applications work, though.

Combining modifiers does not register

Hi there,

just stumbled upon this and it is exactly what I was searching for. However I ran into a problem while trying to configure the extension to meet my needs. I tried to add the followindg:

<Super><Shift>n,google-chrome,Google-chrome,

However all I get when pressing that combo is N.

I am on Gnome 44, system is Fedora Silverblue, Wayland Session, using a bluetooth keyboad.

Did I misunderstand the docs regarding the config or is this a (wayland related) bug?

Installation fails on gnome-shell 40.1

When I upgrade it from https://extensions.gnome.org/extension/1336/run-or-raise/ I get an error:

The settings of extension [email protected] had an error:

Error: No property margin on GtkBox

Stack trace:

_init/Gtk.Widget.prototype._init@resource:///org/gnome/gjs/modules/core/overrides/Gtk.js:45:40
buildPrefsWidget@/home/me/.local/share/gnome-shell/extensions/[email protected]/prefs.js:14:14
_init@resource:///org/gnome/Shell/Extensions/js/extensionsService.js:209:40
OpenExtensionPrefsAsync/<@resource:///org/gnome/Shell/Extensions/js/extensionsService.js:122:28
asyncCallback@resource:///org/gnome/gjs/modules/core/overrides/Gio.js:115:22
run@resource:///org/gnome/Shell/Extensions/js/dbusService.js:177:20
main@resource:///org/gnome/Shell/Extensions/js/main.js:19:13
run@resource:///org/gnome/gjs/modules/script/package.js:206:19
start@resource:///org/gnome/gjs/modules/script/package.js:190:8
@/usr/share/gnome-shell/org.gnome.Shell.Extensions:1:17

Bug when cycling through windows (when hotkey hit twice)

First off, thank you for this awesome tool. I cannot tell you how productive this makes me and how much more enjoyable my development process is as a result.

This is how to reproduce the bug:

  • Start any app using a shortcut (e.g. Google Chrome using Super-G)
  • Start any other app using a shortcut. (e.g. GNOME Terminal using Super-T)
  • Use Super-G to go to Chrome. Now use Super-G again and Terminal will show. This repeats...Chrome-Terminal-Chrome etc. Super-G should never take you to Terminal.

This is only a problem when using a single window. The behavior I expect is that if I have a single window, then hitting the hotkey I've assigned will keep me on the app's window. It's strange hitting the hot key for an app and having it take me to another app, then back.

Add support for older versions of gnome-shell

It would be awesome if run-or-raise would run on older versions of gnome-shell. I am using Debian 9 which has an older version of Gnome-Shell, 3.22.2.
At least I suspect that this is why (after trying to hack this extension to my system by modifying the shell-version in the metadata.json) I get an exception:
Exception in callback for signal: extension-found: SyntaxError: class is a reserved identifier @ /home/tylla/.local/share/gnome-shell/extensions/[email protected]/extension.js:61
Btw: thanks for the idea, nice extension, I'm really looking forward to be able to try it.

spawning command writes to syslog

As run-or-raise is running an external command with imports.misc.util.spawnCommandLine, this produces some weird output to /var/log/syslog.

# gnome shell looking glass output
Util = imports.misc.util;
Util.spawnCommandLine("notify-send test")

2023-12-20T15:05:05.613547+01:00 computer gnome-shell[1987]: g_closure_add_invalidate_notifier: assertion 'closure->n_inotifiers < CLOSURE_MAX_N_INOTIFIERS' failed
2023-12-20T15:05:05.630399+01:00 computer gnome-shell[1987]: message repeated 3 times: [ g_closure_add_invalidate_notifier: assertion 'closure->n_inotifiers < CLOSURE_MAX_N_INOTIFIERS' failed]
2023-12-20T15:05:05.630801+01:00 computer systemd[1682]: app-gnome-notify\x2dsend-15295.scope: Couldn't move process 15295 to requested cgroup '/user.slice/user-1000.slice/[email protected]/app.slice/app-gnome-notify\x2dsend-15295.scope': No such process
2023-12-20T15:05:05.630878+01:00 computer systemd[1682]: app-gnome-notify\x2dsend-15295.scope: Failed to add PIDs to scope's control group: No such process
2023-12-20T15:05:05.630914+01:00 computer systemd[1682]: app-gnome-notify\x2dsend-15295.scope: Failed with result 'resources'.
2023-12-20T15:05:05.630959+01:00 computer systemd[1682]: Failed to start app-gnome-notify\x2dsend-15295.scope - Application launched by gnome-shell.
2023-12-20T15:05:05.662868+01:00 computer gnome-shell[1987]: g_closure_add_invalidate_notifier: assertion 'closure->n_inotifiers < CLOSURE_MAX_N_INOTIFIERS' failed

Use <Return> key

I would like to use the following mapping:

<Super><Shift><Return>,kitty,,

Is it possible?
The <Return> key seems not to be understood.

Keymap is null on Gnome 3.38.4

With const Keymap = Gdk.Keymap.get_default() the extension fails on Gnome 3.38.4 on Wayland (see appendix).

Commenting out

const Keymap = Gdk.Keymap.get_for_display(Gdk.Display.get_default())

as written in extension.js fixes the issue.

Appendix

JS ERROR: Extension [email protected]: TypeError: Keymap is null
get_state@/home/johannes/.local/share/gnome-shell/extensions/[email protected]/extension.js:583:17
enable/<@/home/johannes/.local/share/gnome-shell/extensions/[email protected]/extension.js:554:42
enable@/home/johannes/.local/share/gnome-shell/extensions/[email protected]/extension.js:551:22
enable@/home/johannes/.local/share/gnome-shell/extensions/[email protected]/extension.js:597:9
_callExtensionEnable@resource:///org/gnome/shell/ui/extensionSystem.js:167:32
loadExtension@resource:///org/gnome/shell/ui/extensionSystem.js:350:26
_loadExtensions/<@resource:///org/gnome/shell/ui/extensionSystem.js:588:18
collectFromDatadirs@resource:///org/gnome/shell/misc/fileUtils.js:27:28
_loadExtensions@resource:///org/gnome/shell/ui/extensionSystem.js:567:19
_enableAllExtensions@resource:///org/gnome/shell/ui/extensionSystem.js:597:18
_sessionUpdated@resource:///org/gnome/shell/ui/extensionSystem.js:628:18
init@resource:///org/gnome/shell/ui/extensionSystem.js:56:14
_initializeUI@resource:///org/gnome/shell/ui/main.js:269:22
start@resource:///org/gnome/shell/ui/main.js:159:5
@<main>:1:47

No shortcuts file created

I just installed this extension and noticed a small bug when trying to open went to open shortcuts.conf file, either by run-or-raise settings (Gnome Tweaks > run-or-raise > cog icon > click "open shortcuts.conf file" : nothing happens) or by opening the file directly : ~/.local/share/gnome-shell/extensions/[email protected]/shortcuts.conf

Here is the error message :

screenshot from 2018-01-12 17-21-04

run-or-raise v2
gnome-shell 3.26.2
ubuntu 17.10

Of course the fix is obvious (delete it and copy it again from shortcuts.default) but I just wanted to let you know

Feature request: Move to workspace of open window

So, the opposite of move-window-to-active-workspace: I would like to be able to set a shortcut so I move to the workspace of an open window.

If it exists, then I apologize: Using no mode or switch-back-when-focused, the window is pulled to my current workspace.

Gnome team requirements

Logout is still needed under Wayland

Great extension!

It says in Run or Raise prefs that logout is no longer needed after shortcut.conf is edited. I just wanted to bring it to your attention that this does not seem to be the case in Wayland (at least as far as I can tell from my own experience). I still need to logout to have the extension see my changes.

Having to logout makes no difference for me but I thought I'd let you know since it may cause some confusion with your users.

upgrade wipes out shortcuts.conf!

From the e-mail reports:

What's wrong?
My shortcuts.conf got wiped out....again. I received a notification that some extensions have updates available, so I went to the update page. I clicked on the green icon to update and the pop-up window displayed...but then remembered that the last time I updated, my shortcuts.conf got overwritten (see message from qooob). So I either canceled or just left the pop-up up. I went to ~/.local/share/gnome-shell/extensions to backup my shortcuts.conf (which I pretty sure I already did...named it shortcuts.conf.mine) only to see that the entire run-or-raise directory was gone...including my backup.

What have you tried?

Automatically detected errors:

GNOME Shell Extensions did not detect any errors with this extension.

Version information:

Shell version: 3.28.4
Extension version: 4

"Unable to grab accelerator" when binding ` (backtick) key

I'm trying to bind the backtick key (above Tab on a US keyboard). I tried all of these:

`,gnome-terminal,gnome-terminal-server,
# OR
<Super>`,gnome-terminal,gnome-terminal-server,
# OR
<Backtick>,gnome-terminal,gnome-terminal-server,

, but I always get an Unable to grab accelerator error notification, and journalctl shows an error

gnome-shell[1457]: Window manager warning: "`" is not a valid accelerator

Even though xev shows this key as just a backtick:

KeyPress event, serial 37, synthetic NO, window 0x800001,
    root 0x49a, subw 0x0, time 5449839, (1580,-10), root:(1680,159),
    state 0x0, keycode 49 (keysym 0x60, grave), same_screen YES,
    XLookupString gives 1 bytes: (60) "`"
    XmbLookupString gives 1 bytes: (60) "`"
    XFilterEvent returns: False

I'm able to bind other keys, but this one in particular, no.

Environment

  • run-or-raise d72a218 (May 12, 2023)
  • Shell 43.4 on Wayland on Debian 12.0
  • Happy to provide more debug info if you need more

Context / rationale for this binding

Binding the very accessible backtick key to quickly access a console is common in id software games (Quake, Doom, etc), and nowadays it's burned into my brain.

Thanks for the extension ❤️ . I've been using my own lil' "marathon" wmctrl-based script to run-or-raise apps in Xorg for decades, and am hopeful your extension will let me survive the transition to Wayland 😄 . Kudos for maintaining it, and good choice on making shortcuts.conf a dumb file, it'll be a pleasure to manage/sync with other dotfiles 🙂 .

Mention out-of-the-box alternative (ab)using GNOME Shell "switch-to-application-N" dconf entries

Hi there.

I've been enjoying your extension for a couple months. But while installing a new machine, came the inevitable (for me) quest to minimize extension usage, for reasons you can imagine: I have nothing against extension authors, but I do have a gripe against GNOME Shell major upgrades breaking extensions (as extensions monkeypatch and have no stable API).

Turns out, I was able to find a way! To get a basic "native" (a.k.a. no extension) run-or-raise under Shell,

  1. Pin your favorite apps to Activities
  2. Set dconf values org.gnome.shell.keybindings / switch-to-application-N to your desired keyboard shortcut (where N is 1..9), replacing / adding to default <Super+N>
  3. Never re-order your pinned apps

That's it; enjoy a basic run-or-raise in Shell with no extension! Mentioning it here, in case it interests passerbys, or in case it's helpful next time the extension is broken after a Shell major upgrade. Maybe it's something you could mention in an ## Alternatives section of the README.

Caveats

  • Limited to 9 apps! Choose wisely! 😄
  • No wmclass-regex support, limited to your .desktop entries WMClass
  • No run-or-raise fancy "Modes"

Feature request: Layered shortcuts

Run or raise is amazing, and it makes my day, every day. I think it would be a great addition if it supported layered shortcuts.

Beyond the type of use cases described next, with layered shortcuts Run or raise would add a new dimension of shortcut customizability to GNOME.

A use case and how I hack it with a remapper

With the remapper keyd, I use Super + f, a to run-or-raise a Dolphin tab in one directory, Super + f, b to run-or-raise a tab in another, etc.

As Run or raise does not support such layered shortcuts, with keyd, I map Super+f to activate a second layer, where a triggers the key combination <Super><Control><Alt>a, etc. In my Run or raise config, I then have lines such as

<Super><Control><Alt>a:move-window-to-active-workspace:minimize-when-unfocused,dolphin /home/user/,dolphin, Home
<Super><Control><Alt>b:move-window-to-active-workspace:minimize-when-unfocused,dolphin /home/user/Downloads/,dolphin, Downloads
...

Idea

The shortcut syntax allows a break character (e.g., ,), so shortcuts may be specified as <Super>f,a, meaning that Super + f waits for additional input, and if a is given, then it executes the matching command.

An example of a config for the above use case could then be

<Super>f,a:move-window-to-active-workspace:minimize-when-unfocused,dolphin /home/user/,dolphin, Home
<Super>f,b:move-window-to-active-workspace:minimize-when-unfocused,dolphin /home/user/Downloads/,dolphin, Downloads
...

Feature request: Ability to run commands as root/with sudo

Hi. Due to the ease with which all shortcuts can be exported/imported from this extension, I have decided to use it for all my custom keyboard shortcut needs rather than the fedora custom keyboard shortcut config application.

I have, however, ran into an issue when trying to bind a shortcut to a command which requires root privileges. Is it currently possible to execute commands which require root privileges using this extension? many thx!

PCManFM not raised, but Dolphin is

PCManFM and Dolphin both have the nice feature that they open new tabs in the existing window when you send them a command to open a directory.

However, they behave differently under Run or Raise. Dolphin behaves as I would expect. Using

<Super>a:move-window-to-active-workspace:minimize-when-unfocused,dolphin,dolphin,
<Super>b:move-window-to-active-workspace,dolphin ~/Downloads,dolphin,Downloads,

<Super>a raises and lowers Dolphin, and <Super>b opens a new tab at Downloads and brings the window to the foreground on the current workspace. Great!

But not so for PCManFM.

<Super>c:move-window-to-active-workspace:minimize-when-unfocused,pcmanfm,Pcmanfm,
<Super>d:move-window-to-active-workspace,pcmanfm ~/Downloads,Pcmanfm,Downloads,

Here, <Super>c works as intended, but <Super>d does not: if PCManFM is not focused on a Downloads tab, then the tab will be opened and I get a notification that my window is ready, but it is not moved to the current workspace, nor is it raised on the workspace it is on. (If a Downloads tab is focused, the window will be raised/brought to the current workspace).

Using <Super>d , <Super>c does the intended, but I would be nice to not have to do the <Super>c.

Can you suggest me a hack to get PCManFM to behave?

wm.get_center is not a function

On raising a window from behind the following error is logged:

Mar 11 09:42:12 johannes gnome-shell[1512272]: JS ERROR: TypeError: wm.get_center is not a function
                                               focusWindow@/home/johannes/.local/share/gnome-shell/extensions/[email protected]/extension.js:227:24
                                               jumpapp/<@/home/johannes/.local/share/gnome-shell/extensions/[email protected]/extension.js:132:21
                                               _onAccelerator@/home/johannes/.local/share/gnome-shell/extensions/[email protected]/extension.js:61:13
                                               wrapper@resource:///org/gnome/gjs/modules/_legacy.js:82:22
                                               _init/<@/home/johannes/.local/share/gnome-shell/extensions/[email protected]/extension.js:25:17

It's certainly not a critical bug because everything works a expected.

I just want you to know

wmclass regex clash

When having wmclass Google-chrome called, it also triggers Google-chrome-beta. It shouldn't happen, as it gets impossible to call only Google Chrome, without calling Google Chrome Beta.

Example:

<Shift>F1,gtk-launch google-chrome.desktop,Google-chrome,
<Shift><Alt>c,gtk-launch google-chrome-beta.desktop,Google-chrome-beta,

Clicking Shift+F1 in my case always calls (circles) Google Chrome Beta as well.

Can this be fixed?

Gnome 3.32 / Ubuntu 19.04 support?

Hi! I like this extension very much.

Would it be possible to update it for Gnome 3.32 / Ubuntu 19.04? Currently, it does not appear to be doing anything on that version.

Maybe I can fix it myself if you have any pointers on where to start.

Thanks!

minimize-when-unfocused does not minimize when unfocusing

When cycling through more than one window using

<Super>2:minimize-when-unfocused,kitty,

the instances that lose focus are nor minimized. It seems that once more than one window is in the cycle, the minimization is disabled.

Is this intended?

<Application> is ready notifications on Gnome Shell 41.0

On Fedora 35 with Gnome shell 41 on Wayland, every time I switch between windows using a shortcut, a notification shows up saying the window I'm switching to is ready. This notification isn't useful so if possible it should be removed.

Shortcut to Nautilus does not cycle through windows

Ubuntu 22.04, Wayland

With nautilus (and perhaps other applications, there is erroneous behavior when multiple windows are open:

f,nautilus,nautilus, # same for: nautilus,org.gnome.Nautilus,

does not cycle through the open windows. What is worse, the same window is always focussed, even if previously, another nautilus window was selected.

Steps to reproduce:
Empty desktop

  1. Define shortcut key as above
  2. Hit the shortcut to open a nautilus window. Hit Ctrl+N to open a second nautilus window
  3. Open a browser
  4. Press shortcut key: the second nautilus window is focused (correctly, thus far)
  5. Press shortcut key again: nothing changes (expected: the other nautilus window is now focused)
  6. Press Alt+key-above-tab to bring first nautilus window in focus
  7. Switch to browser
  8. Press shortcut key: the second nautilus window is focused (expected: the first window should be focused)

This erroneous behavior is specific to nautilus - it works correctly with e.g. multiple windows of gedit or firefox.

Auto-update seems to have broken the extension

I noticed today that the extension no longer works. It seems to have auto-updated to version 7 and then it got disabled in the process:

image

When I look at the extension website https://extensions.gnome.org/extension/1336/run-or-raise/ I see this:

image

There's no further information about the supposed "ERROR" and that thing is not clickable. I can open the extension settings just fine but no error is shown there either.

Uninstalling and reinstalling ends in the same "ERROR" state with no additional error message shown anywhere.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.