aboutsummaryrefslogtreecommitdiff
path: root/home/profiles/sway.nix
diff options
context:
space:
mode:
authorFranck Cuny <franck@fcuny.net>2023-05-05 19:41:58 -0700
committerFranck Cuny <franck@fcuny.net>2023-05-05 19:41:58 -0700
commit43da9edb4598eef509c481ae0b305384418c45de (patch)
treea0ad614c90102757143e026e4fe1806431a3dbf4 /home/profiles/sway.nix
parentprofiles/default: users are immutable (diff)
downloadinfra-43da9edb4598eef509c481ae0b305384418c45de.tar.gz
home/profiles: move (almost) all modules to profiles
This is a major refactor, similar to what was done for the hosts, but in a single commit.
Diffstat (limited to 'home/profiles/sway.nix')
-rw-r--r--home/profiles/sway.nix172
1 files changed, 172 insertions, 0 deletions
diff --git a/home/profiles/sway.nix b/home/profiles/sway.nix
new file mode 100644
index 0000000..0665556
--- /dev/null
+++ b/home/profiles/sway.nix
@@ -0,0 +1,172 @@
+{ config, lib, pkgs, ... }:
+let
+ modifier = "Mod4"; # `Super` key
+in
+{
+ imports = [
+ ./gtk.nix
+ ./mako.nix
+ ./waybar.nix
+ ./wofi.nix
+ ];
+
+ home.packages = with pkgs; [
+ wlogout
+ brightnessctl
+ pulseaudio
+ grim
+ slurp
+ polkit_gnome
+ xsettingsd
+ swaylock
+ swayidle
+ wl-clipboard
+ ];
+
+ home.sessionVariables = {
+ MOZ_ENABLE_WAYLAND = "1";
+ XDG_CURRENT_DESKTOP = "sway";
+ XDG_SESSION_TYPE = "wayland";
+ };
+
+ programs = {
+ zsh.loginExtra = ''
+ if [ $(ps ax | grep "[s]sh-agent" | wc -l) -eq 0 ] ; then
+ eval $(ssh-agent -s) > /dev/null
+ fi
+ if [ "$(tty)" = "/dev/tty1" ]; then
+ exec sway &> /dev/null
+ fi
+ '';
+
+ zsh.profileExtra = ''
+ if [ $(ps ax | grep "[s]sh-agent" | wc -l) -eq 0 ] ; then
+ eval $(ssh-agent -s) > /dev/null
+ fi
+ if [ "$(tty)" = "/dev/tty1" ]; then
+ exec sway &> /dev/null
+ fi
+ '';
+ };
+
+ wayland.windowManager.sway = {
+ enable = true;
+ # in order to import some variables (e.g. PATH) so that all the
+ # units that will be started have all the required environment
+ # variables
+ extraSessionCommands = "systemctl --user import-environment";
+ # this will start sway-session.target and run
+ # dbus-update-activation-environment
+ systemdIntegration = 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" = [{ app_id = "org.gnome.Fractal"; }];
+ };
+
+ output = {
+ "*" = {
+ scale = "1.5";
+ bg = "#2E3440 solid_color";
+ };
+ # This is for aptos
+ "eDP-1" = { scale = "1.3"; };
+ };
+ };
+ };
+
+ xdg.configFile."swaylock/config".source = pkgs.writeText "config" ''
+ color=2E3440
+ daemonize
+ indicator-caps-lock
+ hide-keyboard-layout
+ '';
+
+ services.swayidle = {
+ enable = true;
+ events = [
+ {
+ event = "before-sleep";
+ command = "${pkgs.swaylock}/bin/swaylock -fF";
+ }
+ {
+ event = "lock";
+ command = "${pkgs.swaylock}/bin/swaylock -fF";
+ }
+ ];
+ timeouts = [
+ {
+ timeout = 300;
+ command = "${pkgs.sway}/bin/swaymsg \"output * dpms off\"";
+ resumeCommand = "${pkgs.sway}/bin/swaymsg \"output * dpms on\"";
+ }
+ {
+ timeout = 310;
+ command = "${pkgs.systemd}/bin/loginctl lock-session";
+ }
+ ];
+ };
+}