systray_hints/README.md

64 lines
3.6 KiB
Markdown
Raw Normal View History

2022-02-11 08:03:04 +01:00
We are surprised at the time of this writing that the system tray remains such an obvious bottleneck in the nevertheless ubiquitous fight against mouse-dependency among neckbeards the world over. We present accordingly: systray_hints.
2022-01-07 22:58:30 +01:00
# Overview
2022-01-07 22:18:49 +01:00
2022-02-11 08:03:04 +01:00
When `systray_hints.run()` is executed, a popup widget displays a number next to each icon in the system tray while keygrabber listens for input. The number entered on the keyboard sends a right click to the corresponding icon and the original position of the mouse pointer is restored. For most programs this opens a context menu the user may then navigate using arrows and the Return key. To cancel, submit any invalid entry; in practice this includes the Escape key as well as whatever keybinding was configured to launch the function.
2022-01-07 22:18:49 +01:00
2022-02-11 08:03:04 +01:00
The configured mouse button (right-click by default) can be overridden before entering a selection by pressing the Left or Right arrow key for a left or right click, respectively. Alternatively, pressing the Up arrow key will substitute hovering for clicking to display a given icon's tooltip, if any.
2022-01-07 22:58:30 +01:00
2022-02-11 08:03:04 +01:00
If ten or more icons are displayed, the keygrabber will interpret the "1" key as the first digit of the selection and wait for the second digit, or for the Return key to select the first icon. Up to 19 icons are supported.
2022-01-07 22:18:49 +01:00
2022-02-09 00:42:18 +01:00
# Install
2022-01-07 22:18:49 +01:00
2022-02-09 00:42:18 +01:00
cd ~/.config/awesome
2022-02-14 16:47:36 +01:00
git clone https://github.com/ryanthomas-org/systray_hints
2022-01-07 22:18:49 +01:00
2022-02-10 07:53:04 +01:00
Add `systray_hints = require("systray_hints")` to rc.lua. Note this may work better at the end of the file.
2022-01-07 22:58:30 +01:00
2022-02-09 00:42:18 +01:00
# Configuration
2022-02-11 08:03:04 +01:00
Configure by overriding systray_hints table values after the require statement. For example, set the font, left-click by default, and redefine the keybindings for left-click [1], hover [2], and right-click [3].
systray_hints = require("systray_hints")
systray_hints.font = "Iosevka Bold 16"
systray_hints.default_button = 1
systray_hints.mouse_buttons = { "h", "j", "l" }
2022-02-09 00:42:18 +01:00
If the system tray is normally hidden in your environment and toggled as needed with a keybinding, you can replace that keybinding with something like this:
2022-01-07 22:45:54 +01:00
awful.key({ modkey }, "s", function ()
local s
awful.screen.connect_for_each_screen(
function(screen) if screen.systray then s = screen end
end)
2022-02-09 00:42:18 +01:00
if s.systray.visible then
s.systray.visible = false
2022-01-07 22:45:54 +01:00
else
2022-02-09 00:42:18 +01:00
systray_hints.run()
2022-01-07 22:45:54 +01:00
end
2022-02-09 00:42:18 +01:00
end, {description="toggle systray with hints", group="awesome"}),
2022-02-11 08:03:04 +01:00
The `systray_hints.run()` function will automatically unhide the system tray as needed and will return it to its original visiblity state whenever a selection is not made, such as when the key combination is pressed again.
2022-02-09 00:42:18 +01:00
If your system tray is always displayed, simply create a keybinding like the following:
2022-02-09 00:42:18 +01:00
awful.key({ modkey }, "s", function ()
2022-01-07 22:18:49 +01:00
2022-02-09 00:42:18 +01:00
local s
awful.screen.connect_for_each_screen(
function(screen) if screen.systray then s = screen end
end)
2022-01-07 22:58:30 +01:00
2022-02-09 00:42:18 +01:00
systray_hints.run()
2022-02-09 00:42:18 +01:00
end, {description="toggle systray hints", group="awesome"}),
# Issues
2022-01-07 22:18:49 +01:00
2022-02-09 00:42:18 +01:00
The ability to obtain the geometry of the system tray is not referenced in the awesome API for a reason; in theory it may occasionally return incorrect data, requiring an additional execution of the keybinding.
2022-01-07 22:18:49 +01:00
2022-02-11 08:03:04 +01:00
This project was previously assembled as a quick hack in the form of a shell script requiring iocane, rofi, and xdotool. It has been rewritten as a native lua module for the latest stable release with no external dependencies. While deprecated functions were avoided, we have not yet tested it in the development version.