Closed 13minutes-yt closed 9 months ago
Sounds like a nice feature, though I myself would not make use of it. I'm unfamiliar with desktop programming so I probably won't work on this in the foreseeable future.
I'm happy to assist if you or someone else would like to try adding it to kanata. It shouldn't be too hard to wrap kanata in e.g. Python if it's more familiar and is easier to do GUI programming with. For example, a Python program could run kanata as a subprocess and communicate via stdin and stdout.
I am not a programmer myself. What I use is a simple bash script
if pidof kanata_cmd_allowed | grep [0-9] > /dev/null
then
killall kanata_cmd_allowed && notify-send "kanata killed"
else
$HOME/Documents/scripts/kanata_cmd_allowed --cfg mykanata1.kbd & notify-send "kanata started"
fi
It is for notification when kanata starts or killed. I add the script to a tint2 panel as an executor icon. It cannot be used as a general option I had a look at https://github.com/olback/tray-item-rs, but I didn't understand anything:). All rust thing. hehe
https://github.com/jtroo/kanata/pull/44 Once this is ready to be merged, anyone should be able to connect to a TCP socket on kanata
to receive push notifications of layer changes, and then use that data to update widgets on bars or system tray icons.
FYI, I made a Gnome shell extension to display kanata layer info.
I am seeking to migrate from EPKL which is Windows only because it runs on Autohotkey. This is a huge weakness that Kanata does not share.
However, the way that it handles tray support is very reasonable (if not the best way) and might serve as a good conceptual guide to how to implement tray support in a similar type of application.
44 Once this is ready to be merged, anyone should be able to connect to a TCP socket on
kanata
to receive push notifications of layer changes, and then use that data to update widgets on bars or system tray icons.
This is great. On Windows, we would need to be able to start kanata with a no window mode (as a service maybe ?) Then the client could start kanata, passing arguments like --cfg
and --port
.
About a GUI with tray icon, we could use tauri. It’s cross-platform, use rust to serve a frontend webview. Here is a tray menu example . Like electron but very light and fast. Technically, I guess we could use it to display layer change in a toast overlay. The thing is, do we build kanata using tauri or do we build an external client with tauri to receive layer change and even more ?
I've just released kanata-tray v0.1.0, which is a tray-app wrapper for kanata for Windows and Linux.
https://github.com/rszyma/kanata-tray
PS: Technically should work on macOS too, but I have no way to test it there.
Thanks. This is awesome ! Now kanata can run in the tray only. Do you plan to add
display layer change in a toast overlay
?
I’m the kind of guy who auto hide the windows toolbar. So icon in the tray to show layer status, although awesome, is not very helpful for weirdos like me.
I'm not entirely sure what you mean by "toast overlay"
Can you show an example?
The kind of overlay notification on desktop like the one sent by some keyboard keys state (capslock, num…). It would be great if we could set their position, text color, background color, size, position, duration or fixed.
I quickly google searched how to create this kind of popup, but didn't find any releavant info. An alternative would be to create a native popup in notification area. This can be easily done both on Linux (via notify-send
command) and on Windows (see this).
I faced the same problem with google search in the past. I posted the question on Tauri month ago on how to display those kind of overlay. I got an answer but didn’t have the time to test. I guess it would be the same method with go. Display a window with these properties : decorations: false
, ignoreCursorEvents: true
and focus: false
or any equivalent in golang.
https://github.com/tauri-apps/tauri/discussions/7951
Check this go project : https://github.com/progrium/topframe (mac os unfortunately)
The kind of overlay notification on desktop like the one sent by some keyboard keys state (capslock, num…)
Oh, I thought this was a native windows popup, it turns out it's generated by Logi Options+ https://www.reddit.com/r/Windows11/comments/xqj60m/caps_lock_onoff_notification/
Anyways, I've created an issue in kanata-tray repo to track this feature request: https://github.com/rszyma/kanata-tray/issues/3
I've just released kanata-tray v0.1.0, which is a tray-app wrapper for kanata for Windows and Linux.
I used NUMLOCK
to get an audio and toast warning for dangerous layers, but your tool is much cooler. :)
;; numlock on
nly (cmd-output-keys powershell.exe "if ($([console]::NumberLock) -match 'True') { echo '()' } else { echo '(nlck)' }")
;; numlock off
nln (cmd-output-keys powershell.exe "if ($([console]::NumberLock) -match 'True') { echo '(nlck)' } else { echo '()' }")
base (multi (layer-switch base ) @nln)
numfix (multi (layer-switch numfix) @nly)
Thanks for the great work! Mention of kanata-tray is now included in README.
Dropping this here in case it's helpful. Wrote a script to launch kanata as a background daemon on mac - https://github.com/jtroo/kanata/discussions/1086
I personally like using kanata without system tray but system tray comes in handy to know if kanata is running or not and on which keyboard(or configuration). It can be used at a later stage to control multiple keyboards on and of, or improvement in gui configurations.