~ersen/dotfiles

b7a0fa0f4d1aa3a2e1754f6056d49147d76958e4 — Oğuz Ersen 12 days ago 3c19d4d
sway: add keyboard layouts
4 files changed, 29 insertions(+), 2 deletions(-)

M .config/sway/config
M .config/waybar/config
M .config/waybar/style.css
A .local/bin/switch-kblayout.pl
M .config/sway/config => .config/sway/config +2 -1
@@ 6,7 6,7 @@ set $gray "#6c6c6c"
set $white "#bcbcbc"

input type:keyboard {
    xkb_layout "tr"
    xkb_layout "tr,tr(f),us"
    xkb_numlock enabled
    xkb_options "caps:escape"
}


@@ 54,6 54,7 @@ bindsym $mod+Shift+q kill
bindsym $mod+Shift+x exec swaylock && mpc pause
bindsym $mod+x exec swaylock
bindsym Print exec ss-menu.sh
bindsym Ctrl+Shift+space exec switch-kblayout.pl

bindsym --locked $mod+p exec mpc toggle
bindsym --locked $mod+bracketleft exec mpc seek -6

M .config/waybar/config => .config/waybar/config +5 -1
@@ 1,7 1,11 @@
{
    "height": 30,
    "modules-left": ["sway/workspaces", "sway/mode", "wlr/taskbar"],
    "modules-right": ["memory", "cpu", "temperature", "battery", "backlight", "pulseaudio#source", "pulseaudio", "clock", "idle_inhibitor", "tray"],
    "modules-right": ["memory", "cpu", "temperature", "battery", "backlight", "pulseaudio#source", "pulseaudio", "idle_inhibitor", "sway/language", "clock", "tray"],
    "sway/language": {
        "format": "{long}",
        "tooltip": false
    },
    "sway/mode": {
        "format": "{} ✳"
    },

M .config/waybar/style.css => .config/waybar/style.css +1 -0
@@ 29,6 29,7 @@ label:focus {
#clock,
#cpu,
#idle_inhibitor,
#language,
#memory,
#mode,
#pulseaudio,

A .local/bin/switch-kblayout.pl => .local/bin/switch-kblayout.pl +21 -0
@@ 0,0 1,21 @@
#!/usr/bin/perl

use strict;
use warnings;
use JSON::PP;
use List::Util qw(first);

my $string = `swaymsg -t get_inputs`;
my $inputs = decode_json $string;

my %layouts = (
    'Turkish'      => 'tr(f)',
    'Turkish (F)'  => 'us',
    'English (US)' => 'tr',
);

my $input   = first { defined $_->{xkb_active_layout_name} } @{$inputs};
my $current = $input->{xkb_active_layout_name};
my $next    = $layouts{$current};

exec qw(swaymsg input type:keyboard xkb_layout), $next;