about summary refs log tree commit diff
path: root/home/wm
diff options
context:
space:
mode:
authorFranck Cuny <franck@fcuny.net>2022-04-08 08:30:17 -0700
committerFranck Cuny <franck@fcuny.net>2022-04-08 08:30:17 -0700
commit2aa3e62136109c5c4762e951525d68aff3e1ac5a (patch)
tree0f508cad82717ac70c7da5fd402c9555ce9166d1 /home/wm
parenthome: fix for yt-dlp configuration (diff)
downloadworld-2aa3e62136109c5c4762e951525d68aff3e1ac5a.tar.gz
home: add more configurations for home-manager
Diffstat (limited to '')
-rw-r--r--home/wm/default.nix19
-rw-r--r--home/wm/gammastep/default.nix16
-rw-r--r--home/wm/mako/default.nix28
-rw-r--r--home/wm/sway/default.nix90
-rw-r--r--home/wm/swaylock/config (renamed from users/fcuny/configs/swaylock/config)0
-rw-r--r--home/wm/swaylock/default.nix27
-rw-r--r--home/wm/theme/default.nix63
-rw-r--r--home/wm/waybar/default.nix138
-rw-r--r--home/wm/wofi/default.nix59
9 files changed, 440 insertions, 0 deletions
diff --git a/home/wm/default.nix b/home/wm/default.nix
new file mode 100644
index 0000000..e862696
--- /dev/null
+++ b/home/wm/default.nix
@@ -0,0 +1,19 @@
+{ config, lib, pkgs, ... }:
+let
+  mkRelatedOption = description: relatedWMs:
+    let isActivatedWm = wm: config.my.home.wm.windowManager == wm;
+    in (lib.mkEnableOption description) // {
+      default = builtins.any isActivatedWm relatedWMs;
+    };
+in {
+  imports = [ ./sway ./waybar ./mako ./swaylock ./wofi ./gammastep ./theme ];
+  options.my.home.wm = with lib; {
+    windowManager = mkOption {
+      type = with types; nullOr (enum [ "sway" ]);
+      default = null;
+      example = "sway";
+      description = "Which window manager to use for home session";
+    };
+    waybar = { enable = mkRelatedOption "waybar configuration" [ "sway" ]; };
+  };
+}
diff --git a/home/wm/gammastep/default.nix b/home/wm/gammastep/default.nix
new file mode 100644
index 0000000..0a9c684
--- /dev/null
+++ b/home/wm/gammastep/default.nix
@@ -0,0 +1,16 @@
+{ config, lib, pkgs, ... }:
+let isEnabled = config.my.home.wm.windowManager == "sway";
+in {
+  config = lib.mkIf isEnabled {
+    services.gammastep = {
+      enable = true;
+      #TODO: this needs to come from locale.nix
+      latitude = 37.8715;
+      longitude = -122.273;
+      temperature = {
+        day = 5000;
+        night = 3700;
+      };
+    };
+  };
+}
diff --git a/home/wm/mako/default.nix b/home/wm/mako/default.nix
new file mode 100644
index 0000000..3a13620
--- /dev/null
+++ b/home/wm/mako/default.nix
@@ -0,0 +1,28 @@
+{ config, lib, pkgs, ... }:
+let isEnabled = config.my.home.wm.windowManager == "sway";
+in {
+  config = lib.mkIf isEnabled {
+    home.packages = [
+      pkgs.libnotify # to send notifications
+    ];
+
+    systemd.user.services.mako = {
+      Service = { ExecStart = "${pkgs.mako}/bin/mako"; };
+      Install = { WantedBy = [ "sway-session.target" ]; };
+    };
+
+    # All the options are documented via `man 5 mako`
+    programs.mako = {
+      enable = true;
+      layer = "overlay";
+      # The timeout value is in millisecond
+      defaultTimeout = 30000;
+      # The maximum number of notifications
+      maxVisible = 3;
+      maxIconSize = 24;
+      # Enable pango markup (see https://docs.gtk.org/Pango/pango_markup.html)
+      markup = true;
+      actions = true;
+    };
+  };
+}
diff --git a/home/wm/sway/default.nix b/home/wm/sway/default.nix
new file mode 100644
index 0000000..5a69d75
--- /dev/null
+++ b/home/wm/sway/default.nix
@@ -0,0 +1,90 @@
+{ config, lib, pkgs, ... }:
+let
+  isEnabled = config.my.home.wm.windowManager == "sway";
+  terminal = config.my.home.terminal.program;
+  modifier = "Mod4"; # `Super` key
+in {
+  config = lib.mkIf isEnabled {
+    home.packages = with pkgs; [
+      wlogout
+      brightnessctl
+      pulseaudio
+      grim
+      slurp
+      polkit_gnome
+      xsettingsd
+      swaylock
+      swayidle
+      wl-clipboard
+    ];
+
+    home.sessionVariables = {
+      MOZ_ENABLE_WAYLAND = true;
+      XDG_CURRENT_DESKTOP = "sway";
+      XDG_SESSION_TYPE = "wayland";
+    };
+
+    wayland.windowManager.sway = {
+      enable = true;
+      config = {
+        # FIXME: this should be a variable
+        terminal = "alacritty";
+        modifier = modifier;
+        menu = ''${pkgs.wofi}/bin/wofi -S drun -p "app:" -L 10'';
+        bars = [ ];
+        fonts = {
+          names = [ "Source Code Pro" ];
+          size = 10.0;
+        };
+        keybindings = lib.mkOptionDefault {
+          "XF86AudioRaiseVolume" =
+            "exec ${pkgs.pulseaudio}/bin/pactl set-sink-volume @DEFAULT_SINK@ +5%";
+          "XF86AudioLowerVolume" =
+            "exec ${pkgs.pulseaudio}/bin/pactl set-sink-volume @DEFAULT_SINK@ -5%";
+          "XF86AudioMute" =
+            "exec ${pkgs.pulseaudio}/bin/pactl set-sink-mute @DEFAULT_SINK@ toggle";
+          "XF86AudioMicMute" =
+            "exec ${pkgs.pulseaudio}/bin/pactl set-source-mute @DEFAULT_SOURCE@ toggle";
+          "XF86MonBrightnessDown" =
+            "exec ${pkgs.brightnessctl}/bin/brightnessctl set 5%-";
+          "XF86MonBrightnessUp" =
+            "exec ${pkgs.brightnessctl}/bin/brightnessctl set +5%";
+          "${modifier}+Escape" = "exec ${pkgs.wlogout}/bin/wlogout";
+          "${modifier}+s" =
+            "exec ${pkgs.grim}/bin/grim $(xdg-user-dir DOCUMENTS)/screenshots/$(date +'%Y-%m-%d-%H%M%S_screenshot.png')";
+          "${modifier}+Shift+s" =
+            "exec ${pkgs.slurp}/bin/slurp | ${pkgs.grim}/bin/grim -g - $(xdg-user-dir DOCUMENTS)/screenshots/$(date +'%Y-%m-%d-%H%M%S_screenshot.png')";
+        };
+        window.commands = [{
+          command = "floating enable";
+          criteria.app_id = "pavucontrol";
+        }];
+        input = {
+          "*" = {
+            "xkb_layout" = "us,fr";
+            # map capslock to ctrl, and switch layout using shift+caps
+            "xkb_options" = "ctrl:nocaps,grp:shift_caps_toggle";
+          };
+        };
+        assigns = {
+          "1" = [{ app_id = "emacs"; }];
+          "2" = [{ app_id = "Alacritty"; }];
+          "3" = [{ app_id = "firefox"; }];
+          "4" = [{ class = "Element"; }];
+        };
+        output = {
+          "*" = {
+            scale = "1.5";
+            bg = "#2E3440 solid_color";
+          };
+          # This is for aptos
+          "eDP-1" = { scale = "1.3"; };
+        };
+        startup = [{
+          command = ''
+            exec "systemctl --user import-environment; systemctl --user start sway-session.target"'';
+        }];
+      };
+    };
+  };
+}
diff --git a/users/fcuny/configs/swaylock/config b/home/wm/swaylock/config
index 032695b..032695b 100644
--- a/users/fcuny/configs/swaylock/config
+++ b/home/wm/swaylock/config
diff --git a/home/wm/swaylock/default.nix b/home/wm/swaylock/default.nix
new file mode 100644
index 0000000..3df802a
--- /dev/null
+++ b/home/wm/swaylock/default.nix
@@ -0,0 +1,27 @@
+{ config, lib, pkgs, ... }:
+let isEnabled = config.my.home.wm.windowManager == "sway";
+in {
+  config = lib.mkIf isEnabled {
+    xdg.configFile."swaylock/config" = { source = ./config; };
+
+    # https://github.com/nix-community/home-manager/pull/2610
+    # won't be needed for ever
+    systemd.user.services.swayidle = {
+      Unit.PartOf = [ "sway-session.target" ];
+      Install.WantedBy = [ "sway-session.target" ];
+
+      Service = {
+        Environment =
+          "PATH=${pkgs.bash}/bin:${config.wayland.windowManager.sway.package}/bin";
+        ExecStart = ''
+          ${pkgs.swayidle}/bin/swayidle -w \
+              timeout 300 "${pkgs.swaylock}/bin/swaylock" \
+              timeout 300 'swaymsg "output * dpms off"' \
+                  resume 'swaymsg "output * dpms on"' \
+              before-sleep "${pkgs.swaylock}/bin/swaylock"
+        '';
+        Restart = "on-failure";
+      };
+    };
+  };
+}
diff --git a/home/wm/theme/default.nix b/home/wm/theme/default.nix
new file mode 100644
index 0000000..e466d6c
--- /dev/null
+++ b/home/wm/theme/default.nix
@@ -0,0 +1,63 @@
+{ config, lib, ... }:
+let
+  isEnabled = config.my.home.wm.windowManager == "sway";
+  cfg = config.base16-theme;
+  inherit (lib) mkOption mkMerge mkIf mkEnableOption types;
+  cnotation = builtins.replaceStrings [ "#" ] [ "0x" ];
+  color = default:
+    mkOption {
+      inherit default;
+      type = types.str;
+    };
+  alpha = clr: a: "${clr}${a}";
+in {
+  options.base16-theme = {
+    enable = mkEnableOption "Enable base16 theme systemwide";
+    base00 = color "#2E3440"; # polar night
+    base01 = color "#3B4252"; # polar night
+    base02 = color "#434C5E"; # polar night
+    base03 = color "#4C566A"; # polar night
+    base04 = color "#D8DEE9"; # snow storm
+    base05 = color "#E5E9F0"; # snow storm
+    base06 = color "#ECEFF4"; # snow storm
+    base07 = color "#8FBCBB"; # frost
+    base08 = color "#88C0D0"; # frost
+    base09 = color "#81A1C1"; # frost
+    base0A = color "#5E81AC"; # frost
+    base0B = color "#BF616A"; # aurora
+    base0C = color "#D08770"; # aurora
+    base0D = color "#EBCB8B"; # aurora
+    base0E = color "#A3BE8C"; # aurora
+    base0F = color "#B48EAD"; # aurora
+  };
+
+  config = mkIf isEnabled (mkMerge [({
+    wayland.windowManager.sway.config.colors = rec {
+      focused = {
+        border = cfg.base0A;
+        background = cfg.base0A;
+        text = cfg.base06;
+        indicator = cfg.base0A;
+        childBorder = cfg.base0A;
+      };
+
+      focusedInactive = {
+        border = cfg.base00;
+        background = cfg.base00;
+        text = cfg.base07;
+        indicator = cfg.base00;
+        childBorder = cfg.base00;
+      };
+
+      unfocused = focusedInactive;
+
+      urgent = {
+        border = cfg.base0B;
+        background = cfg.base0B;
+        text = cfg.base05;
+        indicator = cfg.base0B;
+        childBorder = cfg.base0B;
+      };
+    };
+  })]);
+}
diff --git a/home/wm/waybar/default.nix b/home/wm/waybar/default.nix
new file mode 100644
index 0000000..6bc385f
--- /dev/null
+++ b/home/wm/waybar/default.nix
@@ -0,0 +1,138 @@
+{ config, lib, pkgs, ... }:
+let isEnabled = config.my.home.wm.windowManager == "sway";
+in {
+  config = lib.mkIf isEnabled {
+    programs.waybar = {
+      enable = true;
+      systemd = { enable = true; };
+
+      settings = [{
+        layer = "bottom";
+        position = "top";
+        margin-top = 0;
+        margin-left = 0;
+        margin-right = 0;
+        margin-bottom = 0;
+        modules-left = [ "sway/workspaces" "sway/mode" ];
+        modules-right = [ "pulseaudio" "network" "battery" "clock" "tray" ];
+        modules = {
+          "sway/workspaces" = { format = "{name}"; };
+          "sway/mode" = { format = "{}"; };
+          tray = { spacing = 10; };
+          clock = { format = "{: %a %b %d %R}"; };
+          battery = {
+            states = {
+              warning = 30;
+              critical = 15;
+            };
+            format = "ac:{capacity}%";
+            tooltip = true;
+            tooltip-format = "{timeTo} ({capacity}%)";
+          };
+          pulseaudio = {
+            format = "vol:{volume}%";
+            format-bluetooth = "bt:{volume}% {icon} ({format_source})";
+            format-bluetooth-muted = "bt:{volume}%";
+            format-muted = "vol:{volume}%";
+            on-click = "pavucontrol";
+          };
+          "network" = {
+            format-wifi = "{essid}:{signalStrength}%";
+            format-ethernet = "{ipaddr}/{cidr}";
+            format-linked = "{ifname} (No IP)";
+            format-disconnected = "network unavailable";
+            format-alt = "{ifname}: {ipaddr}/{cidr}";
+            tooltip = false;
+          };
+        };
+      }];
+
+      style = ''
+        * {
+          border-radius: 0;
+          border: none;
+          margin: 0;
+          min-height: 0;
+          padding: 0;
+        }
+        #waybar {
+          font-family: Source Code Pro;
+          font-size: 15px;
+        }
+        window#waybar {
+          background-color: rgba(43, 48, 59, 0.5);
+          color: #ffffff;
+          transition-property: background-color;
+          transition-duration: .5s;
+        }
+        #workspaces button {
+          padding: 0 3px;
+          background-color: transparent;
+          color: #888888;
+          box-shadow: inset 0 -3px transparent;
+          font-weight: bold;
+        }
+        #workspaces button.focused {
+          background-color: #285577;
+          border: 1px solid #4c7899;
+          color: #ffffff;
+        }
+        #workspaces button.urgent {
+          background-color: #900000;
+          color: #ffffff;
+          border: 1px solid #2f343a;
+        }
+        #tray {
+          /* No styles */
+        }
+        #clock,
+        #battery,
+        #network,
+        #pulseaudio,
+        #tray,
+        #mode {
+          padding-left: 10px;
+          padding-right: 10px;
+        }
+        #mode {
+          background: #64727D;
+          border-top: 2px solid white;
+          /* To compensate for the top border and still have vertical centering */
+          padding-bottom: 2px;
+        }
+        #clock {
+          /* No styles */
+        }
+        #battery {
+          animation-timing-function: linear;
+          animation-iteration-count: infinite;
+          animation-direction: alternate;
+        }
+        #battery.discharging {
+          color: #90a1ad;
+        }
+        #battery.charging {
+          color: #fffff8;
+        }
+        #battery.warning {
+          border-bottom: 2px solid #ff9e21;
+        }
+        #battery.critical {
+          border-bottom: 2px solid #ff3121;
+        }
+        #network {
+          /* No styles */
+        }
+        #network.disconnected {
+          color: orange;
+        }
+        #pulseaudio {
+          /* No styles */
+        }
+        #pulseaudio.muted {
+          color: #90a1ad;
+        }
+      '';
+    };
+  };
+}
diff --git a/home/wm/wofi/default.nix b/home/wm/wofi/default.nix
new file mode 100644
index 0000000..9ccb4be
--- /dev/null
+++ b/home/wm/wofi/default.nix
@@ -0,0 +1,59 @@
+{ config, lib, pkgs, ... }:
+let isEnabled = config.my.home.wm.windowManager == "sway";
+in {
+  config = lib.mkIf isEnabled {
+    home.packages = with pkgs; [ wofi ];
+    xdg.configFile."wofi/config".text = ''
+      allow_images=true
+      image_size=20px
+      drun-display_generic=true
+      dynamic_lines=true
+    '';
+
+    xdg.configFile."wofi/style.css".text = ''
+      *{
+        font-family: monospace;
+      }
+
+      window {
+        color: #5E81AC;
+        background-color: rgba(27, 27, 28, 0.92);
+        border: 2px solid #75d5ff;
+      }
+
+      #input {
+        margin: 10px 0px;
+        border-radius: 0px;
+        border: none;
+        background: transparent;
+        color: white;
+      }
+
+      #inner-box {
+        background-color: transparent;
+      }
+
+      #outer-box {
+        margin: 0px;
+        padding:5px;
+        background-color: transparent;
+      }
+
+      #text {
+        padding: 5px;
+        color: white;
+      }
+
+      #entry:selected {
+        color: #75d5ff;
+        background-color: transparent;
+        border: 0px;
+      }
+
+      #text:selected {
+        color: #75d5ff;
+        background-color: transparent;
+      }
+    '';
+  };
+}