sway: sync Xwayland keyboard layout
This commit is contained in:
parent
28850abd5b
commit
481af4f88c
4 changed files with 54 additions and 0 deletions
|
|
@ -138,6 +138,10 @@
|
||||||
libinput
|
libinput
|
||||||
libratbag
|
libratbag
|
||||||
];
|
];
|
||||||
|
sway-sync-xkbmap = [
|
||||||
|
xorg.setxkbmap
|
||||||
|
jq
|
||||||
|
];
|
||||||
print-battery-icon = [ ];
|
print-battery-icon = [ ];
|
||||||
controller-battery = [ print-battery-icon ];
|
controller-battery = [ print-battery-icon ];
|
||||||
mouse-battery = [ print-battery-icon ];
|
mouse-battery = [ print-battery-icon ];
|
||||||
|
|
|
||||||
22
scripts/sway-sync-xkbmap
Executable file
22
scripts/sway-sync-xkbmap
Executable file
|
|
@ -0,0 +1,22 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
LAST_LAYOUT=""
|
||||||
|
|
||||||
|
while sleep 1s; do
|
||||||
|
CURRENT_LAYOUT=$(swaymsg -t get_inputs | jq -r '.[]|.xkb_active_layout_name|select(.)' | head -n1)
|
||||||
|
|
||||||
|
if test "$LAST_LAYOUT" = "$CURRENT_LAYOUT"; then
|
||||||
|
true
|
||||||
|
elif test "$CURRENT_LAYOUT" = "English (Colemak)"; then
|
||||||
|
echo "Setting layout to colemak"
|
||||||
|
setxkbmap us colemak
|
||||||
|
elif test "$CURRENT_LAYOUT" = "Portuguese (Brazil)"; then
|
||||||
|
echo "Setting layout to br"
|
||||||
|
setxkbmap br
|
||||||
|
fi
|
||||||
|
|
||||||
|
LAST_LAYOUT="$CURRENT_LAYOUT"
|
||||||
|
done
|
||||||
|
|
||||||
|
|
@ -14,6 +14,7 @@ in
|
||||||
imports = [
|
imports = [
|
||||||
./kanshi.nix
|
./kanshi.nix
|
||||||
./mako.nix
|
./mako.nix
|
||||||
|
./sway-sync-xkbmap.nix
|
||||||
./sway-binds.nix
|
./sway-binds.nix
|
||||||
./sway-modes.nix
|
./sway-modes.nix
|
||||||
./sway-assigns.nix
|
./sway-assigns.nix
|
||||||
|
|
|
||||||
27
user/sway/sway-sync-xkbmap.nix
Normal file
27
user/sway/sway-sync-xkbmap.nix
Normal file
|
|
@ -0,0 +1,27 @@
|
||||||
|
{
|
||||||
|
config,
|
||||||
|
pkgs,
|
||||||
|
lib,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
let
|
||||||
|
cfg = config.my.sway;
|
||||||
|
in
|
||||||
|
{
|
||||||
|
config = lib.mkIf cfg.enable {
|
||||||
|
systemd.user.services.sway-sync-xkbmap = {
|
||||||
|
Unit = {
|
||||||
|
Description = "Sync xkbmap with sway keyboard layout";
|
||||||
|
PartOf = [ "graphical-session.target" ];
|
||||||
|
After = [ "graphical-session.target" ];
|
||||||
|
};
|
||||||
|
Service = {
|
||||||
|
ExecStart = lib.getExe pkgs.sway-sync-xkbmap;
|
||||||
|
Restart = "on-failure";
|
||||||
|
};
|
||||||
|
Install = {
|
||||||
|
WantedBy = [ "sway-session.target" ];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue