CLOSED: [2020-02-05 Wed 20:25] :PROPERTIES: :CREATED: [2020-02-05 Wed 17:41] :ID: 2020-02-05-xfce4-toggle-plugin :END: :LOGBOOK: - State "DONE" from "DONE" [2020-02-07 Fri 12:05] - State "DONE" from "DONE" [2020-02-06 Thu 15:33] - State "DONE" from "NEXT" [2020-02-05 Wed 20:25] :END: Update 2020-02-06: Difference to libnotify Update 2020-02-07: workaround using =yad= I do have an idea. Unfortunately, my previous experience with C is from another millennia. Therefore, I need to find somebody who wants to invest a couple of hours to implement something that is going to make many [[https://en.wikipedia.org/wiki/Xfce][Xfce]] users happy ones. Including myself. :-) It should not really be complicated because of limited feature-set and almost every sub-part of it was already implemented in other plugins. *** Examples Application: RChat Imagine, you are using a chat software. Let's call it "RChat" for this example. RChat is nifty but lacks Xfce-integration in terms of a plugin that shows you when new messages arrive at your side. However, the developers of RChat are that cool that they provide settings where user-configurable commands can be executed when a message is received. With a hypothetical =xfce4-toggle-plugin=, you are able to get a "new RChat message arrived"-notification by just simple configuration. You add an instance of =xfce4-toggle-plugin= to your panel. In the plugin settings, you define: - name: "RChat" - command executed on mouse click: : xfce4-toggle-plugin --instance "RChat" --deactivate - icons for activated/deactivated: select something beautiful from the pre-installed xfce/system icons Within RChat settings, you use the following command when new messages arrive: : xfce4-toggle-plugin --instance "RChat" --activate With the small downside that you have to disable manually, you now have a notification plugin for RChat although nobody implemented the =xfce4-plugin-rchat= yet. *** xfce4-toggle-plugin In order to provide this kind of functionality, the plugin configure screen should provide settings for the following things: - a unique identification name - used for hover info - used for sending CLI commands - a command that gets executed on main mouse click - similar to the "Run on click" of the [[https://docs.xfce.org/panel-plugins/xfce4-mailwatch-plugin][xfce4-mailwatch-plugin]] - OPTIONAL: a command that gets executed on middle mouse click - similar to the "Run on click" of the [[https://docs.xfce.org/panel-plugins/xfce4-mailwatch-plugin][xfce4-mailwatch-plugin]] - a select functionality for an icon for the activated state - similar to the "Icons" section of the [[https://docs.xfce.org/panel-plugins/xfce4-mailwatch-plugin][xfce4-mailwatch-plugin]] - a select functionality for an icon for the deactivated state - similar to the "Icons" section of the [[https://docs.xfce.org/panel-plugins/xfce4-mailwatch-plugin][xfce4-mailwatch-plugin]] - OPTIONAL: text input field for a message that gets displayed when the icon switches from inactive to active - notification is launched only when status got changed without mouse interaction to avoid notification on user interaction - OPTIONAL: checkbox for "sticky" (user has to click in order to make it disappear) - OPTIONAL: text input field for a message that gets displayed when the icon switches from active to inactive - see previous one A command-line interface (CLI) with parameters like: : xfce4-toggle-plugin --instance "" --activate CLI parameters: - =--activate= - Afterwards, the plugin is displaying the icon specified for the active state. - =--deactivate= - Afterwards, the plugin is displaying the icon specified for the deactivated state. - =--toggle= - Switches from activated to deactivated state if it was activated and the other way round when it was deactivated before. - OPTIONAL: =--execute-primary-cmd= - If used, it executed the command which is configured for the main mouse button. - OPTIONAL: =--execute-secondary-cmd= - If used, it executed the command which is configured for the secondary mouse button. Somebody from the Xfce IRC already provided [[https://github.com/andreldm/xfce4-toggle-plugin][a small stub for this plugin]]. The xfce4 IRC gave positive feedback already as [[https://docs.xfce.org/contribute/start#feature_requests][requested by the feature-request process]]. Since this is a totally new plugin, there is no sub-project where I could have added an issue for this. *** Difference to Libnotify I am perfectly aware of the existance of [[https://github.com/GNOME/libnotify][libnotify]] and the corresponding pop-up notifications on events. I'm using it on a daily basis. The difference to =xfce4-toggle-plugin= is probably subtle. With =libnotify= I am forced to "react" to a given event instantly. Otherwise, I forget the thing that corresponds to the message. The other possibility is to use "sticky" notification messages that stay on-screen until I click on them. I don't want this in business meetings. Further more, I don't want to manually change to the "do not disturb"-status in order to prevent notifications alltogether. Additionally, =libnotify= messages don't offer any kind of interaction in contrast to the icon click options for the =xfce4-toggle-plugin=. *** Examples Application: Background Task Issue To demonstrate the broad applicability of this plugin, I'm going to describe a different use-case for this plugin. If you're fond of scheduled background tasks just like me, you're probably familiar with [[https://en.wikipedia.org/wiki/Cron][cron]]. In general, this concept is really nice but error-handling is somewhat poor. If you don't pay attention, execution errors might never get your attention. If you are not using a method [[id:2019-12-31-appendorgheading][like this]], you might want to use =xfce4-toggle-plugin= for notifications. - name: "mycrontask" - command executed on mouse click: : xfce4-toggle-plugin --instance "mycrontask" --deactivate - icons for activated/deactivated: select something beautiful from the pre-installed xfce/system icons The scheduled cron job gets extended: : /path/to/command --my-parameter 42 || xfce4-toggle-plugin --instance "mycrontask" --activate In case the =/path/to/command= execution fails somehow and its return value is not zero, you get notified via your handy panel icon. As soon as you resolved the issue, you can then deactivate the notification by clicking on it. *** Please Do Step Forward There are tons of thinkable examples where Xfce4-users are able to provide simple graphical feedback on arbitrary things without coding specific plugins. Of course, three are other generic plugins that could be implemented in a similar way: displaying numbers or barcharts and so forth. You already got the idea. So if you do feel that you want to contribute to this small project, *please do step forward*. Fork [[https://github.com/andreldm/xfce4-toggle-plugin][the project stub on GitHub]] and make this idea a reality! I'm happy to support with testing and documentation. Thank you very much in advance! *** Workaround: yad :PROPERTIES: :END: Geoff Beier sent me an email comment where he describes a cool workaround: #+BEGIN_QUOTE Until you get a volunteer, it might be worth experimenting with [[https://github.com/v1cont/yad][yad]] to see if you get what you want. I've been using that to show dialogs from shell scripts, but I noticed recently it can also put an icon in your tray. ~yad --notification --image=/usr/share/app-info/icons/fedora/64x64/rhythmbox.png &>/dev/null &~ On my system, yad comes in its own package but I'd not be surprised to see it bundled with dialog #+END_QUOTE Installation on Xubuntu was easily done with =sudo apt-get install yad= and [[https://sanana.kiev.ua/index.php/yad][examples]] do look interesting. I was not aware of that tool before. With its =--notification= feature with =--image=, I get the main parts of my idea right away. This way, I can configure simple notification commands everywhere. Thanks a bunch! Volunteers for =xfce4-toggle-plugin= still very much appreciated!