kde: sync XWayland keyboard layout with KDE
This commit is contained in:
parent
a25e277019
commit
f77a07d781
4 changed files with 84 additions and 1 deletions
|
|
@ -146,6 +146,13 @@
|
||||||
xorg.setxkbmap
|
xorg.setxkbmap
|
||||||
jq
|
jq
|
||||||
];
|
];
|
||||||
|
kde-sync-xkbmap = [
|
||||||
|
xorg.setxkbmap
|
||||||
|
dbus
|
||||||
|
gnugrep
|
||||||
|
gnused
|
||||||
|
gawk
|
||||||
|
];
|
||||||
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 ];
|
||||||
|
|
|
||||||
51
scripts/kde-sync-xkbmap
Executable file
51
scripts/kde-sync-xkbmap
Executable file
|
|
@ -0,0 +1,51 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
get_layout_display_name() {
|
||||||
|
idx="$1"
|
||||||
|
dbus-send --session --print-reply --dest=org.kde.keyboard /Layouts org.kde.KeyboardLayouts.getLayoutsList 2>/dev/null \
|
||||||
|
| grep 'string "' \
|
||||||
|
| sed 's/.*string "\([^"]*\)".*/\1/' \
|
||||||
|
| awk -v idx="$idx" 'NR%3==0 { if (c++ == idx) { print; exit } }'
|
||||||
|
}
|
||||||
|
|
||||||
|
get_layout_index() {
|
||||||
|
dbus-send --session --print-reply --dest=org.kde.keyboard /Layouts org.kde.KeyboardLayouts.getLayout 2>/dev/null \
|
||||||
|
| awk '/uint32/ { print $2; exit }'
|
||||||
|
}
|
||||||
|
|
||||||
|
LAST_LAYOUT=""
|
||||||
|
|
||||||
|
apply_layout() {
|
||||||
|
idx="$1"
|
||||||
|
CURRENT_LAYOUT=$(get_layout_display_name "$idx")
|
||||||
|
|
||||||
|
if test "$LAST_LAYOUT" = "$CURRENT_LAYOUT"; then
|
||||||
|
return 0
|
||||||
|
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"
|
||||||
|
}
|
||||||
|
|
||||||
|
update_layout() {
|
||||||
|
INDEX=$(get_layout_index)
|
||||||
|
apply_layout "$INDEX"
|
||||||
|
}
|
||||||
|
|
||||||
|
while ! get_layout_index; do
|
||||||
|
sleep 1s
|
||||||
|
done
|
||||||
|
update_layout
|
||||||
|
|
||||||
|
dbus-monitor --session \
|
||||||
|
"type='signal',interface='org.kde.KeyboardLayouts',member='layoutChanged',path='/Layouts'" \
|
||||||
|
| while read -r line; do
|
||||||
|
update_layout
|
||||||
|
done
|
||||||
|
|
@ -4,6 +4,9 @@
|
||||||
config,
|
config,
|
||||||
...
|
...
|
||||||
}:
|
}:
|
||||||
lib.mkIf (config.my.desktop == "kde") {
|
{
|
||||||
|
imports = [ ./kde/kde-sync-xkbmap.nix ];
|
||||||
|
}
|
||||||
|
// lib.mkIf (config.my.desktop == "kde") {
|
||||||
services.gpg-agent.pinentry.package = lib.mkForce pkgs.pinentry-qt;
|
services.gpg-agent.pinentry.package = lib.mkForce pkgs.pinentry-qt;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
22
user/kde/kde-sync-xkbmap.nix
Normal file
22
user/kde/kde-sync-xkbmap.nix
Normal file
|
|
@ -0,0 +1,22 @@
|
||||||
|
{
|
||||||
|
config,
|
||||||
|
pkgs,
|
||||||
|
lib,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
lib.mkIf (config.my.desktop == "kde") {
|
||||||
|
systemd.user.services.kde-sync-xkbmap = {
|
||||||
|
Unit = {
|
||||||
|
Description = "Sync xkbmap with KDE keyboard layout";
|
||||||
|
PartOf = [ "graphical-session.target" ];
|
||||||
|
After = [ "graphical-session.target" ];
|
||||||
|
};
|
||||||
|
Service = {
|
||||||
|
ExecStart = lib.getExe pkgs.kde-sync-xkbmap;
|
||||||
|
Restart = "on-failure";
|
||||||
|
};
|
||||||
|
Install = {
|
||||||
|
WantedBy = [ "plasma-workspace.target" ];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue