simplified functions and re-wrote readme
This commit is contained in:
parent
a33365f6e2
commit
8e24fc50cb
|
@ -1 +1,2 @@
|
|||
old/
|
||||
old.bak/
|
||||
|
|
28
README.md
28
README.md
|
@ -8,13 +8,15 @@ When "exec.sh" is executed, the included files are referenced to display an inte
|
|||
|
||||
The script uses "awesome-client" to load and call functions from the included lua file. A consequent limitation is the inability to grab data in the shell from lua return statements directly. My approach therefore requires some use of global variables and functions.
|
||||
|
||||
We also make use of rofi to function as a keygrabber to receive number inputs with the "-auto-select" flag so that hitting "return" is never necessary except when there are more than 9 icons to choose from. Finally, mouse.coords, iocane (https://github.com/TrilbyWhite/Iocane), and xdotool are used to simulate mouse actions.
|
||||
We also make use of rofi to function as a keygrabber to receive number inputs with the "-auto-select" flag so that hitting "return" is never necessary except when there are more than 9 icons to choose from. Finally, awesome's built-in mouse module, [iocane](https://github.com/TrilbyWhite/Iocane), and xdotool are used to simulate mouse actions.
|
||||
|
||||
Because the number hints are displayed in the form of a popup widget, visibility of rofi is redundant. An "invisible" theme file has been provided, and assumes a compositor is running. This proved more reliable for us in our tests than enabling rofi's -normal-window mode and attempting to hide the window in rules, and the temporary reassignment of key commands in awesome was one of the relevant matters beyond our immediate grasp. It may also be possible in place of widgets to configure rofi to display options with fixed widths that could be tied to the geometry of the systray icons, but this would become unintuitive in any use case where multi-digit numbers are necessary.
|
||||
Because the number hints are displayed in the form of a popup widget, visibility of rofi is redundant. An "invisible" theme file has been provided, and assumes a compositor is running. This proved more reliable for us in our tests than enabling rofi's -normal-window mode and attempting to hide the window in rules, and the temporary reassignment of key commands in awesome through the keygrabber module was out of our immediate reach.
|
||||
|
||||
# Configuration
|
||||
# Usage / Configuration
|
||||
|
||||
We have been using the following function in global keys to make this as seamless as possible in our environment, where the systray is always hidden by default until needed and our script thus hides it whenever escaped.
|
||||
If the system tray is normally visible in your environment, it should be sufficient to run the script from a terminal or call it from `awful.util.spawn_with_shell` in a global keybinding. You will likely want to comment out the `hide` variable, or else your systray will disappear when you escape out of hints mode.
|
||||
|
||||
On our system, we hide the systray until it is needed, and thus a single keybinding is configured to display it and run this script at once. After interacting with the system tray through the script, the system tray will normally remain visible until the same keybinding is run again to hide it.
|
||||
|
||||
awful.key({ modkey }, "s", function ()
|
||||
|
||||
|
@ -25,8 +27,7 @@ We have been using the following function in global keys to make this as seamles
|
|||
if not s.systray.visible then
|
||||
s.systray.visible = true
|
||||
gears.timer.delayed_call(function()
|
||||
awful.util.spawn_with_shell("$HOME/scripts/systray-hints/exec.sh")
|
||||
end)
|
||||
awful.util.spawn_with_shell("$HOME/scripts/systray-hints/exec.sh") end)
|
||||
else
|
||||
s.systray.visible = false
|
||||
if client.focus and client.focus.instance == "rofi" then
|
||||
|
@ -35,12 +36,21 @@ We have been using the following function in global keys to make this as seamles
|
|||
end
|
||||
|
||||
end, {description="toggle system tray", group="awesome"}),
|
||||
|
||||
Here one key combination is used to hide the systray if it is visible, or if not, to display the systray along with the number hints. Sometimes one may wish only to see what is running in the systray rather than actually click on anything in it, immediately pressing the same key combination to hide it. However, "Super+S" will never be received by the window manager when rofi (in its normal, non-windowed state) is in use. The "exit_key" variable, which should be assigned a single letter as its value, is added by the script to the list of valid options, which are themselves all numbers. The default value is "s" to pair with "Super+S". If we hit Super+S while rofi is active, rofi will read it as simply "s", which later triggers the script to clear the value. This allows us to hit the same combination key to cancel/hide the systray and hints as we do to display them. To disable this, exit_key can be set to null or simply commented out. Rofi can always be escaped via the "Escape" key, which should yield exactly the same result.
|
||||
|
||||
One may sometimes wish to run the above keybinding and, without making a selection, immediately press the same key combination a second time to cancel. The escape key suits this purpose efficiently. However, when rofi is in use, our keybinding will never be received by the window manager; the super key will be ignored, and the key pressed simultaneously will be entered into rofi as input.
|
||||
|
||||
The "exit_key" variable should thus be assigned as its value the same character to which the script is bound, which should not be a number, and in our case is "S" by default to match our above example keybinding "Super+S." In the keybinding function provided, this allows one to press "Super+S" to display the systray with hints and press it again to cancel.
|
||||
|
||||
Moreover, only modifiers that rofi ignores should be used for the keybinding. This allows for the Super and/or Alt keys, but not the Control key, the functions of which have been noted above.
|
||||
|
||||
# Issues
|
||||
|
||||
Additionally, note that obtaining the geometry of the system tray is not directly references in the awesome API for a reason; sometimes it is incorrect and requires a second execution to display correctly. If the same shortcut key is elected to display systray hints as well as to hide them, and one encounters a situation where several icons appear but only one or two hints display. A series of two quick taps of the shortcut key is usually sufficient to resolve it right away.
|
||||
The ability to obtain the geometry of the system tray is not referenced in the awesome API for a reason; sometimes it is incorrect and requires a second execution to display correctly. Occasionally one encounters a situation where several icons appear but only one or two hints display. In the example configuration provided, a series of two quick taps of the shortcut key is usually sufficient to resolve it right away.
|
||||
|
||||
# To Do (Dependencies)
|
||||
|
||||
This script as-is requires iocane, rofi, and xdotool to function. This can no doubt be minimized. It should be re-written without the shell layer, making use of the keygrabber and mouse modules. The current version also contains "bashisms," which some people find offensive.
|
||||
|
||||
As a more wm-neutral alternative, it may also be possible in place of widgets to configure rofi to display options with fixed widths tied to the geometry of the systray icons, but this would become unintuitive in any use case where multi-digit numbers become necessary. One may also elect to incorporate this functionality directly into a standalone systray application such as [trayer-srg](https://github.com/sargon/trayer-srg).
|
||||
|
||||
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.
|
9
exec.sh
9
exec.sh
|
@ -3,10 +3,11 @@
|
|||
|
||||
# See "README" ! Tested with awesome v4.3
|
||||
|
||||
script_path="$(dirname $(realpath "$BASH_SOURCE"))"
|
||||
script_path="$(dirname "$(realpath "$BASH_SOURCE")")"
|
||||
rofi_theme="${script_path}/invisible.rasi" #key grabber only
|
||||
exit_key='s' # See "README" !
|
||||
hover_time='3' #time to hover in seconds if Ctrl+O
|
||||
hide=true #for hidden systray environment, rehide when escaping/canceling
|
||||
|
||||
deps=( awesome-client iocane rofi xdotool )
|
||||
for i in "${deps[@]}"; do command -v "$i" >/dev/null ||
|
||||
|
@ -19,7 +20,7 @@ parse_string() { printf '%s\n' "$1" | awk '{$1=""}1' | sed 's|[ "]||g' ; }
|
|||
|
||||
awesome-exec() {
|
||||
local file
|
||||
[[ "$(realpath "$1")" == "$1" ]] && file="$1" || file="${script_path}/${1}"
|
||||
file="${script_path}/${1}"
|
||||
[ -f "$file" ] && awesome-client 'dofile("'"$file"'")' ||
|
||||
{ echo "Could not find ${1}."; exit 1; }
|
||||
}
|
||||
|
@ -45,7 +46,7 @@ mouse_to_icon() {
|
|||
|
||||
get_choice() {
|
||||
choice=$(seq_with_exit_key "$icon_count" | rofi \
|
||||
-kb-custom-1 "Ctrl+l" -kb-custom-2 "Ctrl+o" -dmenu -theme "$rofi_theme" \
|
||||
-kb-custom-1 "Ctrl+l" -kb-custom-2 "Ctrl+o" -dmenu -i -theme "$rofi_theme" \
|
||||
-no-custom -auto-select 2>/dev/null )
|
||||
code="$?"
|
||||
}
|
||||
|
@ -76,7 +77,7 @@ get_choice; [[ "$code" == "10" ]] && { mouse_button='1'; get_choice; }
|
|||
hide_systray_hints
|
||||
|
||||
[[ "$choice" == "$exit_key" ]] && unset choice
|
||||
[[ -z "$choice" ]] && { hide_systray; exit 0; }
|
||||
[[ -z "$choice" ]] && { [[ "$hide" == "true" ]] && hide_systray; exit 0; }
|
||||
|
||||
mouse_to_icon "$choice" &&
|
||||
|
||||
|
|
|
@ -1,13 +1,11 @@
|
|||
/**
|
||||
* ROFI Color theme
|
||||
* User: Qball
|
||||
* Copyright: Dave Davenport
|
||||
* Invisible theme to use ROFI as a key grabber
|
||||
* Based on a theme by Dave Davenport
|
||||
*/
|
||||
* {
|
||||
background-color: rgba ( 255, 255, 255, 0 % );
|
||||
border-color: rgba ( 255, 255, 255, 0 % );
|
||||
text-color: rgba ( 255, 255, 255, 0 % );
|
||||
font: "Times New Roman 12";
|
||||
}
|
||||
|
||||
#window {
|
||||
|
|
Loading…
Reference in New Issue