Add keyboard layout to waybar.

This commit is contained in:
Érico Rolim 2019-09-09 01:00:19 -03:00
parent 89ebdb0baa
commit c5cf5dc9e3
4 changed files with 41 additions and 8 deletions

View File

@ -0,0 +1,25 @@
#!/usr/bin/env bash
# prints the current keyboard layout and then any layout changes
# taken from https://github.com/Alexays/Waybar/pull/85
swaymsg --type get_inputs --raw | \
jq --raw-output \
'[
.[] |
select(.type == "keyboard") |
.xkb_active_layout_name |
select(contains("English \\(US\\)") | not)
] |
first |
sub("English \\(US\\)"; "us") | sub("Portuguese \\(Brazil\\)"; "br")
'
swaymsg --type subscribe --monitor --raw '["input"]' | \
jq --raw-output --unbuffered \
'
select(.change == "xkb_layout") |
.input.xkb_active_layout_name |
sub("English \\(US\\)"; "us") | sub("Portuguese \\(Brazil\\)"; "br")
'

View File

@ -42,10 +42,8 @@ bindsym $mod+Shift+e exec swaynag -t warning -m 'You pressed the exit shortcut.
set $keyboard "1:1:AT_Translated_Set_2_keyboard" set $keyboard "1:1:AT_Translated_Set_2_keyboard"
input $keyboard { input $keyboard {
xkb_layout "us,br" xkb_layout "us,br"
xkb_options grp:win_space_toggle
} }
#TODO: make script that automatically switches inputs
bindsym $mod+Space input $keyboard xkb_switch_layout 0
bindsym $mod+Shift+Space input $keyboard xkb_switch_layout 1
# Touchpad # Touchpad
set $touchpad "1739:31251:SYNA2393:00_06CB:7A13_Touchpad" set $touchpad "1739:31251:SYNA2393:00_06CB:7A13_Touchpad"
input $touchpad { input $touchpad {
@ -227,9 +225,9 @@ assign [title="CubeMX"] $wsn
exec swaymsg 'workspace pdf; layout tabbed' exec swaymsg 'workspace pdf; layout tabbed'
assign [class="okular"] $wsp assign [class="okular"] $wsp
# Return to first workspace # Return to first workspace
exec swaymsg 'workspace 1' exec swaymsg 'workspace 1;'
## Application specific settings ## Application specific settings
for_window [class="krunner"] floating enable; for_window [class="krunner"] floating enable;
for_window [class="konsole"] floating enable; for_window [class="konsole"] floating enable;
for_window [class="pavucontrol"] floating enable; for_window [class="pavucontrol"] floating enable;

View File

@ -4,9 +4,9 @@
"height": 25, // Waybar height (to be removed for auto height) "height": 25, // Waybar height (to be removed for auto height)
// "width": 1280, // Waybar width // "width": 1280, // Waybar width
// Choose the order of the modules // Choose the order of the modules
"modules-left": ["sway/workspaces", "sway/mode", "custom/media"], "modules-left": ["sway/workspaces", "sway/mode", "custom/media", "tray"],
"modules-center": ["sway/window"], "modules-center": ["sway/window"],
"modules-right": ["mpd", "idle_inhibitor", "pulseaudio", "network", "cpu", "memory", "temperature", "backlight", "battery", "clock", "tray"], "modules-right": ["mpd", "idle_inhibitor", "pulseaudio", "network", "cpu", "memory", "temperature", "backlight", "battery", "custom/keyboard_layout", "clock"],
// Modules configuration // Modules configuration
// "sway/workspaces": { // "sway/workspaces": {
// "disable-scroll": true, // "disable-scroll": true,
@ -142,5 +142,9 @@
"escape": true, "escape": true,
"exec": "$HOME/.config/waybar/mediaplayer.py 2> /dev/null" // Script in resources folder "exec": "$HOME/.config/waybar/mediaplayer.py 2> /dev/null" // Script in resources folder
// "exec": "$HOME/.config/waybar/mediaplayer.py --player spotify 2> /dev/null" // Filter player based on name // "exec": "$HOME/.config/waybar/mediaplayer.py --player spotify 2> /dev/null" // Filter player based on name
},
"custom/keyboard_layout": {
"format": "🎹 {}", // piano keyboard. Normal keyboard: ⌨️
"exec": "keyboard_layout_monitor"
} }
} }

View File

@ -75,12 +75,18 @@ window#waybar.chromium {
#custom-media, #custom-media,
#tray, #tray,
#mode, #mode,
#idle_inhibitor { #idle_inhibitor,
#custom-keyboard_layout {
padding: 0 10px; padding: 0 10px;
margin: 0 4px; margin: 0 4px;
color: #ffffff; color: #ffffff;
} }
#custom-keyboard_layout {
background-color: #b190b1;
color: #ffffff;
}
#clock { #clock {
background-color: #64727D; background-color: #64727D;
} }