From 713d0476c69c06d6baad9568c0d4def8c1e9fae9 Mon Sep 17 00:00:00 2001 From: Franck Cuny Date: Fri, 25 Feb 2022 06:42:48 -0800 Subject: sway: re-organize the modules Rename 'sway' to 'wm' to make it more generic; rename some of the other modules (e.g. 'wofi' to 'launcher'), for the same reason. --- users/fcuny/desktop/default.nix | 2 +- users/fcuny/desktop/sway/default.nix | 112 --------------------------------- users/fcuny/desktop/sway/gammastep.nix | 14 ----- users/fcuny/desktop/sway/i3status.nix | 36 ----------- users/fcuny/desktop/sway/sway-idle.nix | 27 -------- users/fcuny/desktop/sway/wofi.nix | 77 ----------------------- users/fcuny/desktop/wm/bar.nix | 33 ++++++++++ users/fcuny/desktop/wm/default.nix | 90 ++++++++++++++++++++++++++ users/fcuny/desktop/wm/gammastep.nix | 14 +++++ users/fcuny/desktop/wm/launcher.nix | 77 +++++++++++++++++++++++ users/fcuny/desktop/wm/screenlock.nix | 27 ++++++++ users/fcuny/desktop/wm/screenshot.nix | 8 +++ 12 files changed, 250 insertions(+), 267 deletions(-) delete mode 100644 users/fcuny/desktop/sway/default.nix delete mode 100644 users/fcuny/desktop/sway/gammastep.nix delete mode 100644 users/fcuny/desktop/sway/i3status.nix delete mode 100644 users/fcuny/desktop/sway/sway-idle.nix delete mode 100644 users/fcuny/desktop/sway/wofi.nix create mode 100644 users/fcuny/desktop/wm/bar.nix create mode 100644 users/fcuny/desktop/wm/default.nix create mode 100644 users/fcuny/desktop/wm/gammastep.nix create mode 100644 users/fcuny/desktop/wm/launcher.nix create mode 100644 users/fcuny/desktop/wm/screenlock.nix create mode 100644 users/fcuny/desktop/wm/screenshot.nix (limited to 'users/fcuny') diff --git a/users/fcuny/desktop/default.nix b/users/fcuny/desktop/default.nix index 2b60b3f..c19eb6f 100644 --- a/users/fcuny/desktop/default.nix +++ b/users/fcuny/desktop/default.nix @@ -6,10 +6,10 @@ ./emacs.nix ./gtk.nix ./media - ./sway ./syncthing.nix ./terminal.nix ./trust + ./wm ./xdg.nix ]; diff --git a/users/fcuny/desktop/sway/default.nix b/users/fcuny/desktop/sway/default.nix deleted file mode 100644 index 2aa5731..0000000 --- a/users/fcuny/desktop/sway/default.nix +++ /dev/null @@ -1,112 +0,0 @@ -{ config, lib, pkgs, ... }: - -{ - imports = [ - ./i3status.nix - ./sway-idle.nix - ./wofi.nix - ./gammastep.nix - ]; - - home.packages = [ - pkgs.pavucontrol - pkgs.wev - pkgs.wf-recorder - pkgs.wofi - ]; - - home.sessionVariables = { - MOZ_ENABLE_WAYLAND = true; - XDG_CURRENT_DESKTOP = "sway"; - XDG_SESSION_TYPE = "wayland"; - }; - - wayland.windowManager.sway = { - enable = true; - systemdIntegration = true; - extraSessionCommands = '' - export XDG_SESSION_TYPE=wayland - export XDG_CURRENT_DESKTOP=sway - export MOZ_ENABLE_WAYLAND=1 - ''; - config = rec { - modifier = "Mod4"; - terminal = "${config.programs.alacritty.package}/bin/alacritty"; - menu = "${pkgs.wofi}/bin/wofi -S run"; - bars = [ - { - fonts = { - names = [ - "Source Code Pro" - "Font Awesome 5 Free" - ]; - size = 9.0; - style = "Bold"; - }; - extraConfig = '' - position top - ''; - statusCommand = "${pkgs.i3status-rust}/bin/i3status-rs ~/.config/i3status-rust/config-default.toml"; - colors = { - background = "#000000"; - statusline = "#88C0D0"; - separator = "#3B4252"; - focusedWorkspace = { - border = "#88C0D0"; - background = "#88C0D0"; - text = "#2E3440"; - }; - activeWorkspace = { - border = "#4C566ADD"; - background = "#4C566ADD"; - text = "#D8DEE9"; - }; - inactiveWorkspace = { - border = "#000000"; - background = "#000000"; - text = "#E5E9F0"; - }; - urgentWorkspace = { - border = "#B48EAD"; - background = "#B48EAD"; - text = "#ECEFF4"; - }; - bindingMode = { - border = "#BF616A"; - background = "#BF616A"; - text = "#E5E9F0"; - }; - }; - } - ]; - 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%"; - }; - input = { - "*" = { - "xkb_layout" = "us,fr"; - # map capslock to ctrl, and switch layout using shift+caps - "xkb_options" = "ctrl:nocaps,grp:shift_caps_toggle"; - }; - }; - output = { - "*" = { - scale = "1.5"; - }; - # This is for aptos - "eDP-1" = { - scale = "1.3"; - }; - }; - }; - }; -} diff --git a/users/fcuny/desktop/sway/gammastep.nix b/users/fcuny/desktop/sway/gammastep.nix deleted file mode 100644 index 510cb10..0000000 --- a/users/fcuny/desktop/sway/gammastep.nix +++ /dev/null @@ -1,14 +0,0 @@ -{ config, lib, pkgs, ... }: - -{ - services.gammastep = { - enable = true; - #TODO: this needs to come from locale.nix - latitude = 37.8715; - longitude = -122.2730; - temperature = { - day = 5000; - night = 3700; - }; - }; -} diff --git a/users/fcuny/desktop/sway/i3status.nix b/users/fcuny/desktop/sway/i3status.nix deleted file mode 100644 index 9eb5733..0000000 --- a/users/fcuny/desktop/sway/i3status.nix +++ /dev/null @@ -1,36 +0,0 @@ -{ pkgs, ... }: - -{ - programs.i3status-rust = { - enable = true; - bars.default = { - settings.theme.name = "plain"; - icons = "awesome5"; - blocks = [ - { - block = "net"; - format = "{ssid} {signal_strength} {ip}"; - interval = 5; - } - { - block = "battery"; - interval = 30; - format = "{percentage} {time}"; - } - { - block = "backlight"; - } - { - block = "sound"; - on_click = "${pkgs.pavucontrol}/bin/pavucontrol"; - } - { - block = "time"; - interval = 1; - format = "%b-%d %H:%M:%S"; - icons_format = ""; - } - ]; - }; - }; -} diff --git a/users/fcuny/desktop/sway/sway-idle.nix b/users/fcuny/desktop/sway/sway-idle.nix deleted file mode 100644 index 24fde8c..0000000 --- a/users/fcuny/desktop/sway/sway-idle.nix +++ /dev/null @@ -1,27 +0,0 @@ -{ pkgs, config, ... }: - -{ - - xdg.configFile."swaylock/config" = { - source = ../../configs/swaylock/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/users/fcuny/desktop/sway/wofi.nix b/users/fcuny/desktop/sway/wofi.nix deleted file mode 100644 index bc69e0d..0000000 --- a/users/fcuny/desktop/sway/wofi.nix +++ /dev/null @@ -1,77 +0,0 @@ -{ pkgs, config, ... }: - -{ - home.packages = with pkgs; [ - wofi - ]; - - xdg.configFile."wofi/config".text = '' - xoffset=710 - yoffset=275 - show=drun - width=500 - height=500 - always_parse_args=true - show_all=true - print_command=true - layer=overlay - insensitive=true - prompt= - term=${config.wayland.windowManager.sway.config.terminal} - ''; - - xdg.configFile."wofi/style.css".text = '' - window { - margin: 0px; - border: 2px solid #414868; - border-radius: 5px; - background-color: #24283b; - font-family: monospace; - font-size: 12px; - } - - #input { - margin: 5px; - border: 1px solid #24283b; - color: #c0caf5; - background-color: #24283b; - } - - #input image { - color: #c0caf5; - } - - #inner-box { - margin: 5px; - border: none; - background-color: #24283b; - } - - #outer-box { - margin: 5px; - border: none; - background-color: #24283b; - } - - #scroll { - margin: 0px; - border: none; - } - - #text { - margin: 5px; - border: none; - color: #c0caf5; - } - - #entry:selected { - background-color: #414868; - font-weight: normal; - } - - #text:selected { - background-color: #414868; - font-weight: normal; - } - ''; -} diff --git a/users/fcuny/desktop/wm/bar.nix b/users/fcuny/desktop/wm/bar.nix new file mode 100644 index 0000000..265513d --- /dev/null +++ b/users/fcuny/desktop/wm/bar.nix @@ -0,0 +1,33 @@ +{ pkgs, ... }: + +{ + programs.i3status-rust = { + enable = true; + bars.default = { + settings.theme.name = "plain"; + icons = "awesome5"; + blocks = [ + { + block = "net"; + format = "{ssid} {signal_strength} {ip}"; + interval = 5; + } + { + block = "battery"; + interval = 30; + format = "{percentage} {time}"; + } + { + block = "sound"; + on_click = "${pkgs.pavucontrol}/bin/pavucontrol"; + } + { + block = "time"; + interval = 1; + format = "%b-%d %H:%M:%S"; + icons_format = ""; + } + ]; + }; + }; +} diff --git a/users/fcuny/desktop/wm/default.nix b/users/fcuny/desktop/wm/default.nix new file mode 100644 index 0000000..0880b1c --- /dev/null +++ b/users/fcuny/desktop/wm/default.nix @@ -0,0 +1,90 @@ +{ config, lib, pkgs, ... }: + +{ + imports = [ + ./bar.nix + ./gammastep.nix + ./launcher.nix + ./screenlock.nix + ./screenshot.nix + ]; + + home.packages = [ + pkgs.pavucontrol + pkgs.wev + pkgs.wf-recorder + pkgs.wofi + ]; + + home.sessionVariables = { + MOZ_ENABLE_WAYLAND = true; + XDG_CURRENT_DESKTOP = "sway"; + XDG_SESSION_TYPE = "wayland"; + }; + + wayland.windowManager.sway = { + enable = true; + systemdIntegration = true; + extraSessionCommands = '' + export XDG_SESSION_TYPE=wayland + export XDG_CURRENT_DESKTOP=sway + export MOZ_ENABLE_WAYLAND=1 + ''; + config = rec { + modifier = "Mod4"; + terminal = "${config.programs.alacritty.package}/bin/alacritty"; + menu = "${pkgs.wofi}/bin/wofi -S run"; + bars = [ + { + fonts = { + names = [ + "Source Code Pro" + "Font Awesome 5 Free" + ]; + size = 10.0; + }; + position = "top"; + statusCommand = "${pkgs.i3status-rust}/bin/i3status-rs ~/.config/i3status-rust/config-default.toml"; + } + ]; + 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}+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 = [ + # pavucontrol + { + 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"; + }; + }; + output = { + "*" = { + scale = "1.5"; + bg = "#32324b solid_color"; + }; + # This is for aptos + "eDP-1" = { + scale = "1.3"; + }; + }; + }; + }; +} diff --git a/users/fcuny/desktop/wm/gammastep.nix b/users/fcuny/desktop/wm/gammastep.nix new file mode 100644 index 0000000..510cb10 --- /dev/null +++ b/users/fcuny/desktop/wm/gammastep.nix @@ -0,0 +1,14 @@ +{ config, lib, pkgs, ... }: + +{ + services.gammastep = { + enable = true; + #TODO: this needs to come from locale.nix + latitude = 37.8715; + longitude = -122.2730; + temperature = { + day = 5000; + night = 3700; + }; + }; +} diff --git a/users/fcuny/desktop/wm/launcher.nix b/users/fcuny/desktop/wm/launcher.nix new file mode 100644 index 0000000..bc69e0d --- /dev/null +++ b/users/fcuny/desktop/wm/launcher.nix @@ -0,0 +1,77 @@ +{ pkgs, config, ... }: + +{ + home.packages = with pkgs; [ + wofi + ]; + + xdg.configFile."wofi/config".text = '' + xoffset=710 + yoffset=275 + show=drun + width=500 + height=500 + always_parse_args=true + show_all=true + print_command=true + layer=overlay + insensitive=true + prompt= + term=${config.wayland.windowManager.sway.config.terminal} + ''; + + xdg.configFile."wofi/style.css".text = '' + window { + margin: 0px; + border: 2px solid #414868; + border-radius: 5px; + background-color: #24283b; + font-family: monospace; + font-size: 12px; + } + + #input { + margin: 5px; + border: 1px solid #24283b; + color: #c0caf5; + background-color: #24283b; + } + + #input image { + color: #c0caf5; + } + + #inner-box { + margin: 5px; + border: none; + background-color: #24283b; + } + + #outer-box { + margin: 5px; + border: none; + background-color: #24283b; + } + + #scroll { + margin: 0px; + border: none; + } + + #text { + margin: 5px; + border: none; + color: #c0caf5; + } + + #entry:selected { + background-color: #414868; + font-weight: normal; + } + + #text:selected { + background-color: #414868; + font-weight: normal; + } + ''; +} diff --git a/users/fcuny/desktop/wm/screenlock.nix b/users/fcuny/desktop/wm/screenlock.nix new file mode 100644 index 0000000..24fde8c --- /dev/null +++ b/users/fcuny/desktop/wm/screenlock.nix @@ -0,0 +1,27 @@ +{ pkgs, config, ... }: + +{ + + xdg.configFile."swaylock/config" = { + source = ../../configs/swaylock/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/users/fcuny/desktop/wm/screenshot.nix b/users/fcuny/desktop/wm/screenshot.nix new file mode 100644 index 0000000..e396cb7 --- /dev/null +++ b/users/fcuny/desktop/wm/screenshot.nix @@ -0,0 +1,8 @@ +{ config, lib, pkgs, ... }: + +{ + home.packages = [ + pkgs.slurp + pkgs.grim + ]; +} -- cgit 1.4.1