diff --git a/script/.local/bin/keyboard_layout_monitor b/script/.local/bin/keyboard_layout_monitor new file mode 100755 index 0000000..c354c53 --- /dev/null +++ b/script/.local/bin/keyboard_layout_monitor @@ -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") + ' + diff --git a/wm/.config/sway/config b/wm/.config/sway/config index ea6f99e..9e29f51 100644 --- a/wm/.config/sway/config +++ b/wm/.config/sway/config @@ -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" input $keyboard { 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 set $touchpad "1739:31251:SYNA2393:00_06CB:7A13_Touchpad" input $touchpad { @@ -227,9 +225,9 @@ assign [title="CubeMX"] $wsn exec swaymsg 'workspace pdf; layout tabbed' assign [class="okular"] $wsp # Return to first workspace -exec swaymsg 'workspace 1' +exec swaymsg 'workspace 1;' ## Application specific settings for_window [class="krunner"] floating enable; for_window [class="konsole"] floating enable; -for_window [class="pavucontrol"] floating enable; \ No newline at end of file +for_window [class="pavucontrol"] floating enable; diff --git a/wm/.config/waybar/config b/wm/.config/waybar/config index 79000d0..d98cd11 100644 --- a/wm/.config/waybar/config +++ b/wm/.config/waybar/config @@ -4,9 +4,9 @@ "height": 25, // Waybar height (to be removed for auto height) // "width": 1280, // Waybar width // 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-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 // "sway/workspaces": { // "disable-scroll": true, @@ -142,5 +142,9 @@ "escape": true, "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 + }, + "custom/keyboard_layout": { + "format": "🎹 {}", // piano keyboard. Normal keyboard: ⌨️ + "exec": "keyboard_layout_monitor" } } diff --git a/wm/.config/waybar/style.css b/wm/.config/waybar/style.css index b9d3aa5..1df5f35 100644 --- a/wm/.config/waybar/style.css +++ b/wm/.config/waybar/style.css @@ -75,12 +75,18 @@ window#waybar.chromium { #custom-media, #tray, #mode, -#idle_inhibitor { +#idle_inhibitor, +#custom-keyboard_layout { padding: 0 10px; margin: 0 4px; color: #ffffff; } +#custom-keyboard_layout { + background-color: #b190b1; + color: #ffffff; +} + #clock { background-color: #64727D; }