From d441f99bfdfbc3ca3d3f4be3565056b29c04c5a5 Mon Sep 17 00:00:00 2001 From: Leonhard Kargl Date: Thu, 30 May 2024 00:27:57 +0200 Subject: [PATCH 1/2] WindowManager: Add keybindings to launch dock items --- data/gala.gschema.xml | 45 ++++++++++++++++++++++++++++++++++++++++++ src/WindowManager.vala | 24 ++++++++++++++++++++++ 2 files changed, 69 insertions(+) diff --git a/data/gala.gschema.xml b/data/gala.gschema.xml index 518dff717..8cc7b08ad 100644 --- a/data/gala.gschema.xml +++ b/data/gala.gschema.xml @@ -216,6 +216,51 @@ The shortcut to enable picture-in-picture window The shortcut to show the selection area to choose a window. + + 1']]]> + Launch the first dock item + + + + 2']]]> + Launch the second dock item + + + + 3']]]> + Launch the third dock item + + + + 4']]]> + Launch the fourth dock item + + + + 5']]]> + Launch the fith dock item + + + + 6']]]> + Launch the sixth dock item + + + + 7']]]> + Launch the seventh dock item + + + + 8']]]> + Launch the eigth dock item + + + + 9']]]> + Launch the nineth dock item + + diff --git a/src/WindowManager.vala b/src/WindowManager.vala index 80aa321d5..d126e6680 100644 --- a/src/WindowManager.vala +++ b/src/WindowManager.vala @@ -262,6 +262,16 @@ namespace Gala { display.add_keybinding ("window-screenshot-clip", keybinding_settings, Meta.KeyBindingFlags.IGNORE_AUTOREPEAT, (Meta.KeyHandlerFunc) handle_screenshot); display.add_keybinding ("area-screenshot-clip", keybinding_settings, Meta.KeyBindingFlags.IGNORE_AUTOREPEAT, (Meta.KeyHandlerFunc) handle_screenshot); + display.add_keybinding ("launch-dock-1", keybinding_settings, Meta.KeyBindingFlags.IGNORE_AUTOREPEAT, (Meta.KeyHandlerFunc) handle_launch_dock); + display.add_keybinding ("launch-dock-2", keybinding_settings, Meta.KeyBindingFlags.IGNORE_AUTOREPEAT, (Meta.KeyHandlerFunc) handle_launch_dock); + display.add_keybinding ("launch-dock-3", keybinding_settings, Meta.KeyBindingFlags.IGNORE_AUTOREPEAT, (Meta.KeyHandlerFunc) handle_launch_dock); + display.add_keybinding ("launch-dock-4", keybinding_settings, Meta.KeyBindingFlags.IGNORE_AUTOREPEAT, (Meta.KeyHandlerFunc) handle_launch_dock); + display.add_keybinding ("launch-dock-5", keybinding_settings, Meta.KeyBindingFlags.IGNORE_AUTOREPEAT, (Meta.KeyHandlerFunc) handle_launch_dock); + display.add_keybinding ("launch-dock-6", keybinding_settings, Meta.KeyBindingFlags.IGNORE_AUTOREPEAT, (Meta.KeyHandlerFunc) handle_launch_dock); + display.add_keybinding ("launch-dock-7", keybinding_settings, Meta.KeyBindingFlags.IGNORE_AUTOREPEAT, (Meta.KeyHandlerFunc) handle_launch_dock); + display.add_keybinding ("launch-dock-8", keybinding_settings, Meta.KeyBindingFlags.IGNORE_AUTOREPEAT, (Meta.KeyHandlerFunc) handle_launch_dock); + display.add_keybinding ("launch-dock-9", keybinding_settings, Meta.KeyBindingFlags.IGNORE_AUTOREPEAT, (Meta.KeyHandlerFunc) handle_launch_dock); + display.overlay_key.connect (() => { launch_action ("overlay-action"); }); @@ -506,6 +516,20 @@ namespace Gala { } } + [CCode (instance_pos = -1)] + private void handle_launch_dock (Meta.Display display, Meta.Window? window, + Clutter.KeyEvent event, Meta.KeyBinding binding) { + var name = binding.get_name (); + int index = name[name.length - 1] - '0'; + warning (name + " " + index.to_string ()); + + try { + Process.spawn_command_line_async ("io.elementary.dock -i %u".printf (index)); + } catch (Error e) { + warning ("Failed to launch dock item: %s", e.message); + } + } + private void on_gesture_detected (Gesture gesture) { if (workspace_view.is_opened ()) { return; From ccbd0ac6cd1a469ec0fd01c17dabfebd96704ea9 Mon Sep 17 00:00:00 2001 From: Leonhard Kargl Date: Thu, 30 May 2024 00:29:35 +0200 Subject: [PATCH 2/2] Remove debug remnant --- src/WindowManager.vala | 1 - 1 file changed, 1 deletion(-) diff --git a/src/WindowManager.vala b/src/WindowManager.vala index d126e6680..da117c6dd 100644 --- a/src/WindowManager.vala +++ b/src/WindowManager.vala @@ -521,7 +521,6 @@ namespace Gala { Clutter.KeyEvent event, Meta.KeyBinding binding) { var name = binding.get_name (); int index = name[name.length - 1] - '0'; - warning (name + " " + index.to_string ()); try { Process.spawn_command_line_async ("io.elementary.dock -i %u".printf (index));