all repos — flake @ 9c06aaf53f0d8a2255916e32043b6f3fabc9d5f7

got my cool flake

home/common/sway/binds.nix (view raw)

 1
 2
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
 100
 101
 102
 103
 104
 105
 106
 107
 108
 109
 110
 111
 112
 113
 114
 115
 116
 117
 118
 119
 120
{ lib, pkgs, ... }:
let
  programs = {
    term = "foot";
    menu = "dmenu_run";
  };

  workspaces = lib.genAttrs (map toString (lib.range 1 9)) (
    i:
    if
      lib.elem (lib.toInt i) [
        1
        3
        5
        7
        9
      ]
    then
      "DP-1"
    else
      "HDMI-A-1"
  );

  wsBinds = lib.mapAttrs' (ws: output: {
    name = "${super}+${ws}";
    value = "workspace ${ws}";
  }) workspaces;

  wsMoveBinds = lib.mapAttrs' (ws: output: {
    name = "${super}+Shift+${ws}";
    value = "move container to workspace ${ws}";
  }) workspaces;

  super = "Mod4";
  dirKeys = {
    left = "q";
    right = "w";
    up = "a";
    down = "s";
  };

  dirBinds = lib.mapAttrs' (dir: key: {
    name = "${super}+${key}";
    value = "focus ${dir}";
  }) dirKeys;

  dirMoveBinds = lib.mapAttrs' (dir: key: {
    name = "${super}+Shift+${key}";
    value = "move ${dir}";
  }) dirKeys;
in
{
  wayland.windowManager.sway = {
    extraConfig = lib.mkAfter ''
      # workspaces
      ${lib.concatStringsSep "\n" (
        lib.mapAttrsToList (key: cmd: "bindsym ${key} ${cmd}") (
          wsBinds // wsMoveBinds // dirBinds // dirMoveBinds
        )
      )}

      ${lib.concatStringsSep "\n" (
        lib.mapAttrsToList (ws: output: "workspace ${ws} output ${output}") workspaces
      )}

      input type:keyboard {
        xkb_layout gb,us
        xkb_variant ,colemak

        xkb_options caps:ctrl_modifier,grp:win_space_toggle
      }

      # meow
      bindsym ${super}+Shift+e kill
      bindsym ${super}+Shift+c reload;
      bindsym ${super}+Escape exec swaynag -t warning -m 'exit' -B 'yes' 'swaymsg exit'
      floating_modifier ${super} normal

      bindsym ${super}+f fullscreen
      bindsym ${super}+Shift+space floating toggle
      bindsym ${super}+space focus mode_toggle

      # focus & moving
      # bindsym ${super}+${dirKeys.left} focus left
      # bindsym ${super}+${dirKeys.right} focus right
      # bindsym ${super}+${dirKeys.up} focus up
      # bindsym ${super}+${dirKeys.down} focus down

      # bindsym ${super}+${dirKeys.left}+Shift move left
      # bindsym ${super}+${dirKeys.right}+Shift move right
      # bindsym ${super}+${dirKeys.up}+Shift move up
      # bindsym ${super}+${dirKeys.down}+Shift move down

      bindsym ${super}+Shift+Tab move scratchpad
      bindsym ${super}+Tab scratchpad show

      # layout
      bindsym ${super}+z splith
      bindsym ${super}+x splitv
      bindsym ${super}+e layout stacking
      bindsym ${super}+r layout tabbed
      bindsym ${super}+c layout toggle split

      # launch things
      bindsym ${super}+t exec ${programs.term}
      bindsym ${super}+d exec ${programs.menu}

      # media
      bindsym --locked XF86AudioPlay exec playerctl play-pause --ignore-player firefox
      bindsym --locked XF86AudioNext exec playerctl next --ignore-player firefox
      bindsym --locked XF86AudioPrev exec playerctl previous --ignore-player firefox
      bindsym --locked XF86AudioStop exec playerctl stop --ignore-player firefox

      bindsym --locked XF86AudioRaiseVolume exec pactl set-sink-volume @DEFAULT_SINK@ +5%
      bindsym --locked XF86AudioLowerVolume exec pactl set-sink-volume @DEFAULT_SINK@ -5%
      bindsym --locked XF86AudioMicMute exec pactl set-sink-mute @DEFAULT_SINK@ toggle
      bindsym --locked XF86AudioMute exec pactl set-sink-mute @DEFAULT_SINK@ toggle
    '';
  };
}