aboutsummaryrefslogtreecommitdiff
path: root/home/wm
diff options
context:
space:
mode:
Diffstat (limited to 'home/wm')
-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.nix113
-rw-r--r--home/wm/swaylock/config4
-rw-r--r--home/wm/swaylock/default.nix27
-rw-r--r--home/wm/waybar/default.nix52
-rw-r--r--home/wm/waybar/style.css77
-rw-r--r--home/wm/wofi/config4
-rw-r--r--home/wm/wofi/default.nix8
10 files changed, 348 insertions, 0 deletions
diff --git a/home/wm/default.nix b/home/wm/default.nix
new file mode 100644
index 0000000..27a8bf4
--- /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 ];
+ 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..ba70992
--- /dev/null
+++ b/home/wm/sway/default.nix
@@ -0,0 +1,113 @@
+{ 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 {
+ # control the volume
+ "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";
+
+ # control brightness
+ "XF86MonBrightnessDown" =
+ "exec ${pkgs.brightnessctl}/bin/brightnessctl set 5%-";
+ "XF86MonBrightnessUp" =
+ "exec ${pkgs.brightnessctl}/bin/brightnessctl set +5%";
+
+ # logout
+ "${modifier}+Escape" = "exec ${pkgs.wlogout}/bin/wlogout";
+
+ # screenshot
+ "${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')";
+
+ # File Manager
+ "${modifier}+p" = "exec ${pkgs.pcmanfm}/bin/pcmanfm";
+ };
+
+ # use `swaymsg -t get_tree' to get the title/name/ID of the applications
+ window = {
+ commands = [
+ {
+ criteria.class = ".blueman-manager-wrapped";
+ command = "floating enable";
+ }
+ {
+ criteria.class = "Pavucontrol";
+ command = "floating enable";
+ }
+ ];
+ };
+
+ 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/home/wm/swaylock/config b/home/wm/swaylock/config
new file mode 100644
index 0000000..032695b
--- /dev/null
+++ b/home/wm/swaylock/config
@@ -0,0 +1,4 @@
+color=FFFFEA
+daemonize
+indicator-caps-lock
+hide-keyboard-layout
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/waybar/default.nix b/home/wm/waybar/default.nix
new file mode 100644
index 0000000..c1bf601
--- /dev/null
+++ b/home/wm/waybar/default.nix
@@ -0,0 +1,52 @@
+{ 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}%";
+ 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 = (builtins.readFile ./style.css);
+ };
+ };
+}
diff --git a/home/wm/waybar/style.css b/home/wm/waybar/style.css
new file mode 100644
index 0000000..e4565c8
--- /dev/null
+++ b/home/wm/waybar/style.css
@@ -0,0 +1,77 @@
+* {
+ 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.9);
+ color: #ffffff;
+}
+#workspaces button {
+ padding: 0 3px;
+ background-color: transparent;
+ color: #888888;
+}
+#workspaces button.focused {
+ background-color: #285577;
+ border: 1px solid #4c7899;
+ color: #ffffff;
+}
+#workspaces button.urgent {
+ background-color: #900000;
+ border: 1px solid #2f343a;
+ color: #ffffff;
+}
+#clock,
+#battery,
+#network,
+#pulseaudio,
+#tray,
+#mode {
+ padding-left: 10px;
+ padding-right: 10px;
+}
+#mode {
+ /* No styles */
+}
+#tray {
+ /* No styles */
+}
+#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/config b/home/wm/wofi/config
new file mode 100644
index 0000000..95dedba
--- /dev/null
+++ b/home/wm/wofi/config
@@ -0,0 +1,4 @@
+allow_images=true
+image_size=20px
+drun-display_generic=true
+dynamic_lines=true
diff --git a/home/wm/wofi/default.nix b/home/wm/wofi/default.nix
new file mode 100644
index 0000000..ad3c759
--- /dev/null
+++ b/home/wm/wofi/default.nix
@@ -0,0 +1,8 @@
+{ 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".source = ./config;
+ };
+}