Reaching Applets via Keyboard Shortcuts.

Write suggestions and new ideas in here
More ideas here http://community.linuxmint.com/idea/welcome
Forum rules
  • Only post ideas here that are specifically about the Linux Mint distribution or its websites.
  • So that developers and users from any distribution can discuss ideas in one place, post ideas about improving software to the collaboration website for that software instead.
Post Reply
Elagoht
Level 1
Level 1
Posts: 3
Joined: Fri Apr 17, 2020 5:53 am

Reaching Applets via Keyboard Shortcuts.

Post by Elagoht »

I like to do everything with keyboard shortcuts and not to use mouse usually. I want to open notifications applet via Super+A shortcut. It may be a feature request for next release or if there is a solution for this wish, I would like to see your replies.

User avatar
powerwagon75
Level 4
Level 4
Posts: 275
Joined: Sun Feb 28, 2016 4:05 pm
Location: USA

Re: Reaching Applets via Keyboard Shortcuts.

Post by powerwagon75 »

Presuming you're using Cinnamon.

Go to Menu --> Preferences --> Keyboard, and open it up.

Go to the shortcuts tab on top, and then select the Add custom shortcut.

You should have this dialog box pop up..fill it as shown:
applets_shorcut.png
applets_shorcut.png (18.88 KiB) Viewed 784 times
Click the "Add" button. Then highlight by single clicking your new shortcut, then at the bottom under Keyboard Bindings, double-click on the "unassigned", and then press <Super + A> keys and it will record that.

That's it.

edit...apologies..i totally missed the notifications part of your post. Disregard.
Image
Custom tower w/Mint 18
HP laptop w/Mint 18
Acer w/W10/Mint 18.3
Macbook w/El Capitan/Mint 18.3
Optiplex 960 "Frankenbox" w/Fedora 30/Mint 18.3/Mint 19.2
Acer C720 Chromebook w/GalliumOS
Mac PPC G4 w/Lubuntu

Elagoht
Level 1
Level 1
Posts: 3
Joined: Fri Apr 17, 2020 5:53 am

Re: Reaching Applets via Keyboard Shortcuts.

Post by Elagoht »

Yes I'm using Cinnamon. I know how to add shortcuts. Thanks for it but I did'nt mean that. I meant opening applet like this via shortcuts.
Attachments
Untitled.png

User avatar
smurphos
Level 16
Level 16
Posts: 6768
Joined: Fri Sep 05, 2014 12:18 am
Location: Britisher
Contact:

Re: Reaching Applets via Keyboard Shortcuts.

Post by smurphos »

Hi,

This needs a modified version of the Notification applet - applet keybindings are defined in the applet themselves.

Anyway, I've never done this mod before so gave it a go this afternoon - here's the working result.

Edit to add. This is based on the Mint 19.3, Cinnamon 4.4.x version of the notification applet. I've only tested on 19.3, but I think it will work on Mint 19, Cinnamon 3.8.x and later. It probably won't work on Mint 18.3 / Cinnamon 3.6.x and earlier

Edit to add - whilst I was at it I decided to add a keybinding to Clear all Notifications without opening the applet.

Download the attachment and extract into ~/.local/share/cinnamon/applets, then restart Cinnamon with Ctrl-Alt-Esc
notifications@cinnamon.org.zip
(9.5 KiB) Downloaded 14 times
Image

Image
Last edited by smurphos on Sun Apr 19, 2020 12:23 am, edited 4 times in total.
For custom Nemo actions, useful scripts for the Cinnamon desktop, and Cinnamox themes visit my Github pages.

User avatar
smurphos
Level 16
Level 16
Posts: 6768
Joined: Fri Sep 05, 2014 12:18 am
Location: Britisher
Contact:

Re: Reaching Applets via Keyboard Shortcuts.

Post by smurphos »

For reference here's a summary of the changes between the modified version and the original

Code: Select all

steve@steve-Inspiron-5580:~$ diff -u /usr/share/cinnamon/applets/notifications@cinnamon.org ~/.local/share/cinnamon/applets/notifications@cinnamon.org
diff -u /usr/share/cinnamon/applets/notifications@cinnamon.org/applet.js /home/steve/.local/share/cinnamon/applets/notifications@cinnamon.org/applet.js
--- /usr/share/cinnamon/applets/notifications@cinnamon.org/applet.js	2020-01-07 09:41:42.000000000 +0000
+++ /home/steve/.local/share/cinnamon/applets/notifications@cinnamon.org/applet.js	2020-04-19 04:39:50.652111154 +0100
@@ -23,6 +23,9 @@
         this.settings = new Settings.AppletSettings(this, metadata.uuid, instanceId);
         this.settings.bind("ignoreTransientNotifications", "ignoreTransientNotifications");
         this.settings.bind("showEmptyTray", "showEmptyTray", this._show_hide_tray);
+        this.settings.bind("keyOpen", "keyOpen", this._setKeybinding);
+        this.settings.bind("keyClear", "keyClear", this._setKeybinding);
+        this._setKeybinding();
 
         // Layout
         this._orientation = orientation;
@@ -39,6 +42,21 @@
         this._blinking = false;
         this._blink_toggle = false;
     }
+    
+    _setKeybinding() {
+        Main.keybindingManager.addHotKey("notification-open-" + this.instance_id, this.keyOpen, Lang.bind(this, this._openMenu));
+        Main.keybindingManager.addHotKey("notification-clear-" + this.instance_id, this.keyClear, Lang.bind(this, this._clear_all));
+    }
+    
+    on_applet_removed_from_panel () {
+        Main.keybindingManager.removeHotKey("notification-open-" + this.instance_id);
+        Main.keybindingManager.removeHotKey("notification-clear-" + this.instance_id);
+    }
+    
+    _openMenu() {
+        this._update_timestamp();
+        this.menu.toggle();
+    }
 
     _display() {
         // Always start the applet empty, void of any notifications.
@@ -238,8 +256,7 @@
     }
 
     on_applet_clicked(event) {
-        this._update_timestamp();
-        this.menu.toggle();
+        this._openMenu();
     }
 
     _update_timestamp() {
Common subdirectories: /usr/share/cinnamon/applets/notifications@cinnamon.org/icons and /home/steve/.local/share/cinnamon/applets/notifications@cinnamon.org/icons
diff -u /usr/share/cinnamon/applets/notifications@cinnamon.org/settings-schema.json /home/steve/.local/share/cinnamon/applets/notifications@cinnamon.org/settings-schema.json
--- /usr/share/cinnamon/applets/notifications@cinnamon.org/settings-schema.json	2020-01-07 09:41:42.000000000 +0000
+++ /home/steve/.local/share/cinnamon/applets/notifications@cinnamon.org/settings-schema.json	2020-04-18 18:55:13.341929477 +0100
@@ -18,5 +18,21 @@
         "default" : false,
         "description" : "Show empty tray",
         "tooltip" : "Check this to show the tray even when there are no new notifications."
+    },
+        "section3": {
+        "type": "section",
+        "description": "Keyboard shortcuts"
+    },
+        "keyOpen": {
+        "type": "keybinding",
+        "description": "Show notifications",
+        "default": "<Super>n",
+        "tooltip" : "Set keybinding(s) to show the notification popup menu."
+    },
+        "keyClear": {
+        "type": "keybinding",
+        "description": "Clear notifications",
+        "default": "<Shift><Super>c",
+        "tooltip" : "Set keybinding(s) to clear all notifications."
     }
 }

For custom Nemo actions, useful scripts for the Cinnamon desktop, and Cinnamox themes visit my Github pages.

Elagoht
Level 1
Level 1
Posts: 3
Joined: Fri Apr 17, 2020 5:53 am

Re: Reaching Applets via Keyboard Shortcuts.

Post by Elagoht »

Thanks for it. It works well. I would it will become default in new update.

User avatar
smurphos
Level 16
Level 16
Posts: 6768
Joined: Fri Sep 05, 2014 12:18 am
Location: Britisher
Contact:

Re: Reaching Applets via Keyboard Shortcuts.

Post by smurphos »

For custom Nemo actions, useful scripts for the Cinnamon desktop, and Cinnamox themes visit my Github pages.

Post Reply

Return to “Suggestions & New Ideas”