diff --git a/config/automatrop/roles/desktop_environment/tasks/main.yml b/config/automatrop/roles/desktop_environment/tasks/main.yml index fa9f9da..3a5c159 100644 --- a/config/automatrop/roles/desktop_environment/tasks/main.yml +++ b/config/automatrop/roles/desktop_environment/tasks/main.yml @@ -60,39 +60,6 @@ - color - i3 -- name: Download base16 theme for Tridactyl - ansible.builtin.copy: - content: "{{ base16_schemes['schemes'][base16_scheme]['tridactyl']['base16-' + base16_scheme + '.config.py'] }}" - # url: "https://raw.githubusercontent.com/bezmi/base16-tridactyl/master/base16-{{ base16_scheme }}.css" - dest: "{{ ansible_env.HOME }}/.config/tridactyl/themes/theme.css" - mode: u=rw,g=r,o=r - when: false # Not currently used - tags: - - color - -- name: Configure i3 - ansible.builtin.template: - src: "{{ ansible_env.HOME }}/.config/i3/config.j2" - dest: "{{ ansible_env.HOME }}/.config/i3/config" - mode: u=rw,g=r,o=r - notify: - - i3-reload - tags: - - color - - i3 - when: display_server == 'x11' - -- name: Set base16 theme for rofi - ansible.builtin.copy: - content: "{{ base16_schemes['schemes'][base16_scheme]['rofi']['themes']['base16-' + base16_scheme + '.' + item] }}" - dest: "{{ ansible_env.HOME }}/.config/rofi/theme.{{ item }}" - mode: u=rw,g=r,o=r - tags: - - color - loop: - - config - - rasi - - name: Configure Dunst ansible.builtin.template: src: "{{ ansible_env.HOME }}/.config/dunst/dunstrc.j2" diff --git a/config/i3/.gitignore b/config/i3/.gitignore deleted file mode 100644 index d981efa..0000000 --- a/config/i3/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -config -theme diff --git a/config/i3/config.j2 b/config/i3/config.j2 deleted file mode 100644 index 49075f3..0000000 --- a/config/i3/config.j2 +++ /dev/null @@ -1,90 +0,0 @@ -# vi:syntax=conf -# i3 config file (v4) -# Please see http://i3wm.org/docs/userguide.html for a complete reference! - -# Set mod key (Mod1=, Mod4=) -set $mod Mod4 - -# set default desktop layout (default is tiling) -# workspace_layout tabbed - -# Configure border style -new_window pixel 2 -new_float normal - -# Hide borders -hide_edge_borders both - - - - - -mouse_warping output - - - - - - -# Workspace names -set $WS1 1 -set $WS2 2 -set $WS3 3 -set $WS4 4 -set $WS5 5 -set $WS6 6 -set $WS7 7 -set $WS8 8 -set $WS9 9 -set $WS10 10 - -# Workspace output -{% set screens = x11_screens | default(['DEFAULT']) %} -{% for i in range(1, 11) %} -workspace "$WS{{ i }}" output {{ screens[(i - 1) % (screens | length)] }} -{% endfor %} - - - -# Default layout = tabs, since I mostly exclusively use them -workspace_layout tabbed - -# Open specific applications in floating mode -for_window [title="pacmixer"] floating enable border pixel 2 -for_window [class="Firefox"] layout tabbed # Doesn't seem to work anymore -for_window [class="qutebrowser"] layout tabbed - -for_window [window_role="pop-up"] floating enable -for_window [window_role="task_dialog"] floating enable -for_window [ title="^pdfpc.*" window_role="presenter" ] move to output left, fullscreen -for_window [ title="^pdfpc.*" window_role="presentation" ] move to output right, fullscreen - -# switch to workspace with urgent window automatically -for_window [urgent=latest] focus - -# Set shut down, restart and locking features -set $locker $HOME/.config/i3/lock - -# Inactivity settings -exec --no-startup-id xautolock -time 10 -locker 'xset dpms force standby' -killtime 1 -killer '$locker' - "$mod+F1" = "exec --no-startup-id sh -c "sleep .25 && xset dpms force off""; - "$mod+F4" = "exec --no-startup-id xautolock -disable"; - "$mod+F5" = "exec --no-startup-id xautolock -enable"; - - -# Autostart applications -#exec --no-startup-id /usr/lib/polkit-gnome/polkit-gnome-authentication-agent-1 # Password remembering -#exec --no-startup-id gnome-keyring-daemon # Password remembering -# exec --no-startup-id urxvtd -q -f # urxvt daemon -{% if auto_numlock %} -exec --no-startup-id numlockx on # Activate Num lock -{% endif %} -exec --no-startup-id unclutter -root # Hide mouse cursor after some time -#exec --no-startup-id dunst # Notifications (handled by systemd) -exec --no-startup-id keynav # Keyboard cursor controller -#exec --no-startup-id mpd # Music Player Daemon (handled by systemd) -exec --no-startup-id autorandr --change --force # Screen configuration and everything that depends on it -{% if has_battery %} -exec --no-startup-id ~/.config/i3/batteryNotify -d # Battery state notification -{% endif %} - diff --git a/config/i3/batteryNotify b/config/nix/hm/batteryNotify.sh similarity index 92% rename from config/i3/batteryNotify rename to config/nix/hm/batteryNotify.sh index a6a1ed2..73376a5 100755 --- a/config/i3/batteryNotify +++ b/config/nix/hm/batteryNotify.sh @@ -1,5 +1,3 @@ -#!/usr/bin/env bash - BATT="/sys/class/power_supply/BAT0" LOW=10 CRIT=3 @@ -25,10 +23,10 @@ function computeState() { if [ "$acpiStatus" == "Discharging" ] then - if [ $acpiCapacity -le $CRIT ] + if [ "$acpiCapacity" -le $CRIT ] then setState "CRIT" -u critical -i battery-caution "Battery level is critical" "$acpiCapacity %" - elif [ $acpiCapacity -le $LOW ] + elif [ "$acpiCapacity" -le $LOW ] then setState "LOW" -u critical -i battery-low "Battery level is low" "$acpiCapacity %" else diff --git a/config/nix/hm/desktop.nix b/config/nix/hm/desktop.nix index b3a22be..ab6ef78 100644 --- a/config/nix/hm/desktop.nix +++ b/config/nix/hm/desktop.nix @@ -9,32 +9,31 @@ lockColors = { a = "#82a401"; b = "#466c01"; d = "#648901"; }; # Old lockSvg = pkgs.writeText "lock.svg" ""; lockPng = pkgs.runCommand "lock.png" { } "${pkgs.imagemagick}/bin/convert ${lockSvg} $out"; - locker = "exec ${ pkgs.writeShellScript "i3-locker" - '' - # Remove SSH and GPG keys from keystores - ${pkgs.openssh}/bin/ssh-add -D - echo RELOADAGENT | ${pkgs.gnupg}/bin/gpg-connect-agent - ${pkgs.coreutils}/bin/rm -rf "/tmp/cached_pass_$UID" + locker = pkgs.writeShellScript "i3-locker" + '' + # Remove SSH and GPG keys from keystores + ${pkgs.openssh}/bin/ssh-add -D + echo RELOADAGENT | ${pkgs.gnupg}/bin/gpg-connect-agent + ${pkgs.coreutils}/bin/rm -rf "/tmp/cached_pass_$UID" - ${pkgs.lightdm}/bin/dm-tool lock - # TODO Does that work for all DMs? - if [ $? -ne 0 ]; then - if [ -d ${config.xdg.cacheHome}/lockpatterns ] - then - pattern=$(${pkgs.findutils} ${config.xdg.cacheHome}/lockpatterns | sort -R | head -1) - else - pattern=${lockPng} - fi - revert() { - ${pkgs.xorg.xset} dpms 0 0 0 - } - trap revert SIGHUP SIGINT SIGTERM - ${pkgs.xorg.xset} dpms 5 5 5 - ${pkgs.i3lock}/bin/i3lock --nofork --color ${builtins.substring 1 6 lockColors.d} --image=$pattern --tiling --ignore-empty-password - revert - fi - '' - }"; + ${pkgs.lightdm}/bin/dm-tool lock + # TODO Does that work for all DMs? + if [ $? -ne 0 ]; then + if [ -d ${config.xdg.cacheHome}/lockpatterns ] + then + pattern=$(${pkgs.findutils} ${config.xdg.cacheHome}/lockpatterns | sort -R | head -1) + else + pattern=${lockPng} + fi + revert() { + ${pkgs.xorg.xset}/bin/xset dpms 0 0 0 + } + trap revert SIGHUP SIGINT SIGTERM + ${pkgs.xorg.xset}/bin/xset dpms 5 5 5 + ${pkgs.i3lock}/bin/i3lock --nofork --color ${builtins.substring 1 6 lockColors.d} --image=$pattern --tiling --ignore-empty-password + revert + fi + ''; focus = "exec ${ pkgs.writeShellScript "i3-focus-window" '' WINDOW=`${pkgs.xdotool}/bin/xdotool getwindowfocus` @@ -52,6 +51,7 @@ mode_temp = "Temperature [R] Red [D] Dust storm [C] Campfire [O] Normal [A] All nighter [B] Blue"; in { + modifier = "Mod1"; # FIXME Mod1 for VM, Mod4 for not VM terminal = "alacritty"; # bars = []; # FIXME lemonbar colors = let ignore = "#ff00ff"; in @@ -77,7 +77,7 @@ # Compatibility layer for people coming from other backgrounds # "Mod1+Tab" = "${rofi} -modi window -show window"; # FIXME When no longer using a VM "Mod1+F2" = "${rofi} -modi drun -show drun"; - "Mod1+F4" = "kill"; + # "Mod1+F4" = "kill"; # FIXME When no longer using a VM # kill focused window "${mod}+z" = "kill"; button2 = "kill"; @@ -163,6 +163,7 @@ "${mod}+8" = "workspace 8; ${focus}"; "${mod}+9" = "workspace 9; ${focus}"; "${mod}+0" = "workspace 10; ${focus}"; + # TODO Prevent repetitions, see workspace assignation for example #navigate workspaces next / previous "${mod}+Ctrl+h" = "workspace prev_on_output; ${focus}"; "${mod}+Ctrl+l" = "workspace next_on_output; ${focus}"; @@ -204,6 +205,11 @@ "${mod}+Shift+c" = "reload"; "${mod}+Shift+r" = "restart"; "${mod}+Shift+e" = "exit"; + # Screen off commands + "${mod}+F1" = "exec --no-startup-id ${pkgs.bash}/bin/sh -c \"${pkgs.coreutils}/bin/sleep .25 && ${pkgs.xorg.xset}/bin/xset dpms force off\""; + # TODO --release? + "${mod}+F4" = "exec --no-startup-id ${pkgs.xautolock}/bin/xautolock -disable"; + "${mod}+F5" = "exec --no-startup-id ${pkgs.xautolock}/bin/xautolock -enable"; # Modes "${mod}+Escape" = "mode ${mode_system}"; "${mod}+r" = "mode ${mode_resize}"; @@ -217,10 +223,10 @@ }; in { "${mode_system}" = { - "l" = "exec --no-startup-id ${locker}, mode default"; + "l" = "exec --no-startup-id exec ${locker}, mode default"; "e" = "exit, mode default"; - "s" = "exec --no-startup-id ${locker} & ${pkgs.systemd}/bin/systemctl suspend, mode default"; - "h" = "exec --no-startup-id ${locker} & ${pkgs.systemd}/bin/systemctl hibernate, mode default"; + "s" = "exec --no-startup-id exec ${locker} & ${pkgs.systemd}/bin/systemctl suspend, mode default"; + "h" = "exec --no-startup-id exec ${locker} & ${pkgs.systemd}/bin/systemctl hibernate, mode default"; "r" = "exec --no-startup-id ${pkgs.systemd}/bin/systemctl reboot, mode default"; "p" = "exec --no-startup-id ${pkgs.systemd}/bin/systemctl poweroff -i, mode default"; } // return_bindings; @@ -268,8 +274,53 @@ "b" = "exec ${pkgs.sct}/bin/sct 10000"; } // return_bindings; }; + window = { + hideEdgeBorders = "both"; + titlebar = false; # So that single-container screens are basically almost fullscreen + commands = [ + # Open specific applications in floating mode + { criteria = { class = "Firefox"; }; command = "layout tabbed"; } # Doesn't seem to work anymore + { criteria = { class = "qutebrowser"; }; command = "layout tabbed"; } + { criteria = { title = "^pdfpc.*"; window_role = "presenter"; }; command = "move to output left, fullscreen"; } + { criteria = { title = "^pdfpc.*"; window_role = "presentation"; }; command = "move to output right, fullscreen"; } + # switch to workspace with urgent window automatically + { criteria = { urgent = "latest"; }; command = "focus"; } + ]; + }; + floating = { + criteria = [ + { title = "pacmixer"; } + { window_role = "pop-up"; } + { window_role = "task_dialog"; } + ]; + }; + startup = [ + # Lock screen after 10 minutes + { notification = false; command = "${pkgs.xautolock}/bin/xautolock -time 10 -locker '${pkgs.xorg.xset}/bin/xset dpms force standby' -killtime 1 -killer ${locker}"; } + { + notification = false; + command = "${pkgs.writeShellApplication { + name = "batteryNotify"; + runtimeInputs = with pkgs; [coreutils libnotify]; + text = builtins.readFile ./batteryNotify.sh; + # TODO Use batsignal instead? + # TODO Only on computers with battery + }}/bin/batteryNotify"; + } + # TODO There's a services.screen-locker.xautolock but not sure it can match the above command + ]; + workspaceLayout = "tabbed"; + focus.mouseWarping = true; # i3 only supports warping to workspace, hence ${focus} + workspaceOutputAssign = + let + x11_screens = [ "HDMI-1-0" "eDP1" ]; # FIXME Per computer thing + workspaces = map (i: { name = toString i; key = toString (lib.mod i 10); }) (lib.lists.range 1 10); + forEachWorkspace = f: map (w: f { w = w; workspace = ((builtins.elemAt workspaces w)); }) (lib.lists.range 0 ((builtins.length workspaces) - 1)); + in + forEachWorkspace ({ w, workspace }: { output = builtins.elemAt x11_screens (lib.mod w (builtins.length x11_screens)); workspace = workspace.name; }); }; }; + xsession.numlock.enable = true; # FIXME Only on computers with a separate one programs = { # Browser @@ -323,6 +374,15 @@ enable = true; pass.enable = true; }; + autorandr.enable = true; + }; + + xdg.userDirs.enable = true; # TODO Which ones do we want? + services = { + unclutter.enable = true; + dunst.enable = true; + mpd.enable = true; + autorandr.enable = true; }; home.packages = with pkgs; [ @@ -330,7 +390,6 @@ tigervnc # music - mpd mpc-cli ashuffle vimpc @@ -361,13 +420,10 @@ yubikey-touch-detector # x11-exclusive - dunst numlockx # TODO urxvt-resize-font-git simplescreenrecorder trayer - unclutter - xautolock xclip lemonbar-xft keynav