diff --git a/.treefmt.toml b/.treefmt.toml index 6aceea5e..13f06f83 100644 --- a/.treefmt.toml +++ b/.treefmt.toml @@ -7,6 +7,7 @@ excludes = [ "*.patch", "*.ogg", "*.lock", + "*.conf", "License" ] diff --git a/home/file/sway/default.nix b/home/file/sway/default.nix index 00753cf4..ed816e2e 100644 --- a/home/file/sway/default.nix +++ b/home/file/sway/default.nix @@ -1,33 +1,214 @@ { + __findFile, config, lib, + pkgs, util, ... -}@args: +}: let - swayRc = util.catText [ - ./module/Mod.nix - ./module/Style.nix - ./module/Display.nix - ./module/Input.nix - ./module/Font.nix - ./module/Launcher.nix - ./module/Terminal.nix - ./module/TitleBar.nix - ./module/Navigation.nix - ./module/Notification.nix - ./module/Resize.nix - ./module/ScratchPad.nix - ./module/Screenshot.nix - ./module/Sound.nix - ./module/Tiling.nix - ./module/Workspace.nix - ./module/Session.nix - ./module/Keyd.nix - ./module/Waybar.nix - ./module/System.nix - ./module/Mouse.nix - ] args; + fontName = config.module.style.font.sansSerif.name; + keyboardLayouts = config.module.keyboard.layouts; + keyboardOptions = config.module.keyboard.options; + + alpha = config.module.style.opacity.hex; + accent = config.module.style.color.accent + alpha; + border = config.module.style.color.border + alpha; + borderSize = config.module.style.window.border; + fg = config.module.style.color.fg.light; + wallpaper = config.module.wallpaper.path; + windowGap = config.module.style.window.gap; + + codec = "libsvtav1"; + color = config.module.style.color; + container = "mp4"; + format = "%Y-%m-%d_%H-%M-%S"; + framerate = 10; + opacity = "26"; + pixfmt = "yuv420p10le"; + selection = "slurp -d -b ${color.bg.light}${opacity} -c ${color.fg.light} -w 0 -s 00000000"; + + notifyStart = ''swayscript notify_short''; + notifyEnd = ''swayscript notify_long''; + picEdit = ''swappy -f - -o -''; + picFull = ''-o $(swaymsg -t get_outputs | jq -r ".[] | select(.focused) | .name") -''; + picPrepFile = prepFile "\${XDG_PICTURES_DIR[0]}" "png"; + picRefLatestFile = refLatestFile "png"; + picSelected = ''-g "''${scrSelection}" -''; + picToBuffer = ''wl-copy -t image/png''; + picToFile = ''tee "''${scrFile}"''; + screenshot = ''grim''; + updateWaybar = ''{ pkill -RTMIN+4 waybar; } & disown''; # NOTE: Might need to add a delay here if it becomes inconsistent one day. + vidFull = ''-o $(swaymsg -t get_outputs | jq -r ".[] | select(.focused) | .name") -''; + vidPrepFile = prepFile "\${XDG_VIDEOS_DIR[0]}" container; + vidRefLatestFile = refLatestFile container; + vidSelected = ''--geometry "''${scrSelection}"''; + vidStop = ''pkill -SIGINT wf-recorder''; + + prepFile = path: ext: '' + # Focused app id by default. + curWindow=$(parse_snake $(swaymsg -t get_tree | jq '.. | select(.type?) | select(.focused==true) | .app_id')) + + # If no id (i.e. xwayland), then use a name (title). + [[ "''${curWindow}" = "null" ]] && curWindow=$(parse_snake $(swaymsg -t get_tree | jq '.. | select(.type?) | select(.focused==true) | .name')) + + # If no app in focus, use "unknown" dir. + [[ "''${curWindow}" =~ ^[0-9]+$ ]] && curWindow="unknown" + + # Prepare dir and file path. + scrPath="${path}" + scrDir="${path}/''${curWindow}" + mkdir -p "''${scrDir}" + scrName="$(date +${format}).${ext}" + scrFile="''${scrDir}/''${scrName}" + scrLatestRef="./''${curWindow}/''${scrName}" + ''; + + refLatestFile = ext: '' + scrLatest="''${scrPath}/Latest.${ext}" + rm "''${scrLatest}" + ln -s "''${scrLatestRef}" "''${scrLatest}" + ''; + + getSelection = '' + scrSelection=$(${selection}) + [[ -n "''${scrSelection}" ]] || exit + ''; + + getTransform = '' + scrTransform="$(swaymsg -t get_outputs | jq -r '.[] | select(.focused) | .transform')" + [[ "''${scrTransform}" = "normal" ]] && scrTransform="" + ''; + + vidStart = '' + wf-recorder \ + --no-damage \ + --codec ${codec} \ + --file "''${scrFile}" \ + --framerate ${toString framerate} \ + --pixel-format ${pixfmt} \ + ''; + + vidMuxAudio = '' + ffmpeg \ + -f lavfi \ + -i anullsrc=channel_layout=stereo:sample_rate=44100 \ + -i "''${scrFile}" \ + -c:v copy \ + -c:a libopus \ + -shortest \ + -f ${container} \ + "''${scrFile}_" \ + && mv "''${scrFile}_" "''${scrFile}" \ + || rm "''${scrFile}_" + ''; + + vidTransform = '' + if [[ -n "''${scrTransform}" ]]; then + ffmpeg \ + -display_rotation ''${scrTransform} \ + -i "''${scrFile}" \ + -c copy \ + -f ${container} \ + "''${scrFile}_" \ + && mv "''${scrFile}_" "''${scrFile}" \ + || rm "''${scrFile}_" + fi + ''; + + SelectRecording = pkgs.writeShellScriptBin "SelectRecording" '' + ${vidStop} || { + ${getSelection} + ${getTransform} + ${vidPrepFile} + ${notifyStart} + ${updateWaybar} + ${vidStart} ${vidSelected} + ${notifyEnd} + ${updateWaybar} + ${vidMuxAudio} + ${vidTransform} + ${vidRefLatestFile} + }; + ''; + + FullscreenRecording = pkgs.writeShellScriptBin "FullscreenRecording" '' + ${vidStop} || { + ${getTransform} + ${vidPrepFile} + ${notifyStart} + ${updateWaybar} + ${vidStart} ${vidFull} + ${notifyEnd} + ${updateWaybar} + ${vidMuxAudio} + ${vidTransform} + ${vidRefLatestFile} + }; + ''; + + FullscreenScreenshot = pkgs.writeShellScriptBin "FullscreenScreenshot" '' + ${notifyEnd} + ${picPrepFile} + + ${screenshot} ${picFull} | ${picToFile} | ${picToBuffer} + ${picRefLatestFile} + ''; + + SelectScreenshot = pkgs.writeShellScriptBin "SelectScreenshot" '' + ${getSelection} + ${notifyStart} + ${picPrepFile} + + ${screenshot} ${picSelected} | ${picEdit} | ${picToFile} | ${picToBuffer} + ${notifyEnd} + ${picRefLatestFile} + ''; + + swayRcRaw = pkgs.writeText "sway-rc-raw" ( + util.readFiles [ + ./module/Mod.conf + ./module/Style.conf + ./module/Display.conf + ./module/Input.conf + ./module/Font.conf + ./module/Launcher.conf + ./module/Terminal.conf + ./module/TitleBar.conf + ./module/Navigation.conf + ./module/Notification.conf + ./module/Resize.conf + ./module/ScratchPad.conf + ./module/Screenshot.conf + ./module/Sound.conf + ./module/Tiling.conf + ./module/Workspace.conf + ./module/Keyd.conf + ./module/Waybar.conf + ./module/System.conf + ./module/Mouse.conf + ] + ); + + swayRc = (pkgs.replaceVars swayRcRaw { + inherit + FullscreenRecording + FullscreenScreenshot + SelectRecording + SelectScreenshot + accent + border + borderSize + fg + fontName + keyboardLayouts + keyboardOptions + wallpaper + windowGap + ; + }).overrideAttrs (old: { + doCheck = false; + }); in { text = @@ -35,6 +216,6 @@ in # Read `man 5 sway` for a complete reference. include /etc/sway/config.d/* '' - + swayRc + + builtins.readFile swayRc + lib.concatStringsSep "\n" config.module.sway.extraConfig; } diff --git a/home/file/sway/module/Display.conf b/home/file/sway/module/Display.conf new file mode 100644 index 00000000..501173b9 --- /dev/null +++ b/home/file/sway/module/Display.conf @@ -0,0 +1,2 @@ +# You can get the names of your outputs by running: swaymsg -t get_outputs +output * scale 1 diff --git a/home/file/sway/module/Display.nix b/home/file/sway/module/Display.nix deleted file mode 100644 index 94f33b74..00000000 --- a/home/file/sway/module/Display.nix +++ /dev/null @@ -1,7 +0,0 @@ -{ ... }: -{ - text = '' - # You can get the names of your outputs by running: swaymsg -t get_outputs - output * scale 1 - ''; -} diff --git a/home/file/sway/module/Font.conf b/home/file/sway/module/Font.conf new file mode 100644 index 00000000..bf38d5cc --- /dev/null +++ b/home/file/sway/module/Font.conf @@ -0,0 +1 @@ +font "@fontName@ Medium 0.01" diff --git a/home/file/sway/module/Font.nix b/home/file/sway/module/Font.nix deleted file mode 100644 index d8d80a39..00000000 --- a/home/file/sway/module/Font.nix +++ /dev/null @@ -1,9 +0,0 @@ -{ config, ... }: -let - fontName = config.module.style.font.sansSerif.name; -in -{ - text = '' - font "${fontName} Medium 0.01" - ''; -} diff --git a/home/file/sway/module/Input.conf b/home/file/sway/module/Input.conf new file mode 100644 index 00000000..98c5bc47 --- /dev/null +++ b/home/file/sway/module/Input.conf @@ -0,0 +1,42 @@ +### Input configuration +# +# Example configuration: +# +# input "2:14:SynPS/2_Synaptics_TouchPad" { +# dwt enabled +# tap enabled +# natural_scroll enabled +# middle_emulation enabled +# } +# +# You can get the names of your inputs by running: swaymsg -t get_inputs +# Read `man 5 sway-input` for more information about this section. + +input type:pointer { + accel_profile flat + pointer_accel 0 + dwt enabled + tap enabled + natural_scroll enabled + middle_emulation enabled +} + +input type:touchpad { + accel_profile flat + pointer_accel 0 + dwt enabled + tap enabled + natural_scroll enabled + middle_emulation enabled +} + +input type:keyboard { + xkb_layout @keyboardLayouts@ + xkb_options @keyboardOptions@ +} + +# Hide mouse cursor after a period of inactivity. +seat seat0 hide_cursor 5000 + +# Per-window languages. +exec swaykbdd diff --git a/home/file/sway/module/Input.nix b/home/file/sway/module/Input.nix deleted file mode 100644 index bb0bd12f..00000000 --- a/home/file/sway/module/Input.nix +++ /dev/null @@ -1,47 +0,0 @@ -{ config, ... }: -{ - text = '' - ### Input configuration - # - # Example configuration: - # - # input "2:14:SynPS/2_Synaptics_TouchPad" { - # dwt enabled - # tap enabled - # natural_scroll enabled - # middle_emulation enabled - # } - # - # You can get the names of your inputs by running: swaymsg -t get_inputs - # Read `man 5 sway-input` for more information about this section. - - input type:pointer { - accel_profile flat - pointer_accel 0 - dwt enabled - tap enabled - natural_scroll enabled - middle_emulation enabled - } - - input type:touchpad { - accel_profile flat - pointer_accel 0 - dwt enabled - tap enabled - natural_scroll enabled - middle_emulation enabled - } - - input type:keyboard { - xkb_layout ${config.module.keyboard.layouts} - xkb_options ${config.module.keyboard.options} - } - - # Hide mouse cursor after a period of inactivity. - seat seat0 hide_cursor 5000 - - # Per-window languages. - exec swaykbdd - ''; -} diff --git a/home/file/sway/module/Keyd.conf b/home/file/sway/module/Keyd.conf new file mode 100644 index 00000000..06716102 --- /dev/null +++ b/home/file/sway/module/Keyd.conf @@ -0,0 +1 @@ +exec keyd-application-mapper -d diff --git a/home/file/sway/module/Keyd.nix b/home/file/sway/module/Keyd.nix deleted file mode 100644 index 7429d2e4..00000000 --- a/home/file/sway/module/Keyd.nix +++ /dev/null @@ -1,6 +0,0 @@ -{ ... }: -{ - text = '' - exec keyd-application-mapper -d - ''; -} diff --git a/home/file/sway/module/Launcher.conf b/home/file/sway/module/Launcher.conf new file mode 100644 index 00000000..7a08fdae --- /dev/null +++ b/home/file/sway/module/Launcher.conf @@ -0,0 +1,6 @@ +# Application launcher. +# Note: pass the final command to swaymsg so that the resulting window can be opened +# on the original workspace that the command was run on. +set $menu fuzzel + +bindsym $mod+space exec $menu diff --git a/home/file/sway/module/Launcher.nix b/home/file/sway/module/Launcher.nix deleted file mode 100644 index 82b9949b..00000000 --- a/home/file/sway/module/Launcher.nix +++ /dev/null @@ -1,11 +0,0 @@ -{ ... }: -{ - text = '' - # Application launcher. - # Note: pass the final command to swaymsg so that the resulting window can be opened - # on the original workspace that the command was run on. - set $menu fuzzel - - bindsym $mod+space exec $menu - ''; -} diff --git a/home/file/sway/module/Mod.conf b/home/file/sway/module/Mod.conf new file mode 100644 index 00000000..0b69a89f --- /dev/null +++ b/home/file/sway/module/Mod.conf @@ -0,0 +1,3 @@ +# Meta key. Use Mod1 for Alt. +set $mod Mod4 +set $sysmod print diff --git a/home/file/sway/module/Mod.nix b/home/file/sway/module/Mod.nix deleted file mode 100644 index 9041bf15..00000000 --- a/home/file/sway/module/Mod.nix +++ /dev/null @@ -1,8 +0,0 @@ -{ ... }: -{ - text = '' - # Meta key. Use Mod1 for Alt. - set $mod Mod4 - set $sysmod print - ''; -} diff --git a/home/file/sway/module/Mouse.conf b/home/file/sway/module/Mouse.conf new file mode 100644 index 00000000..95bb60b9 --- /dev/null +++ b/home/file/sway/module/Mouse.conf @@ -0,0 +1,3 @@ +bindsym --whole-window $mod+button2 kill +bindsym --whole-window $mod+button8 floating toggle +bindsym --whole-window $mod+button9 fullscreen diff --git a/home/file/sway/module/Mouse.nix b/home/file/sway/module/Mouse.nix deleted file mode 100644 index cb5c66f3..00000000 --- a/home/file/sway/module/Mouse.nix +++ /dev/null @@ -1,8 +0,0 @@ -{ ... }: -{ - text = '' - bindsym --whole-window $mod+button2 kill - bindsym --whole-window $mod+button8 floating toggle - bindsym --whole-window $mod+button9 fullscreen - ''; -} diff --git a/home/file/sway/module/Navigation.conf b/home/file/sway/module/Navigation.conf new file mode 100644 index 00000000..8af5bed4 --- /dev/null +++ b/home/file/sway/module/Navigation.conf @@ -0,0 +1,14 @@ +# Move focus. +bindsym --to-code $mod+a focus left +bindsym --to-code $mod+d focus right +bindsym --to-code $mod+s focus down +bindsym --to-code $mod+w focus up + +# Move the focused window. +bindsym --to-code $mod+Shift+a move left +bindsym --to-code $mod+Shift+d move right +bindsym --to-code $mod+Shift+s move down +bindsym --to-code $mod+Shift+w move up + +# Focus mouse following. +focus_follows_mouse yes diff --git a/home/file/sway/module/Navigation.nix b/home/file/sway/module/Navigation.nix deleted file mode 100644 index 361eb27f..00000000 --- a/home/file/sway/module/Navigation.nix +++ /dev/null @@ -1,19 +0,0 @@ -{ ... }: -{ - text = '' - # Move focus. - bindsym --to-code $mod+a focus left - bindsym --to-code $mod+d focus right - bindsym --to-code $mod+s focus down - bindsym --to-code $mod+w focus up - - # Move the focused window. - bindsym --to-code $mod+Shift+a move left - bindsym --to-code $mod+Shift+d move right - bindsym --to-code $mod+Shift+s move down - bindsym --to-code $mod+Shift+w move up - - # Focus mouse following. - focus_follows_mouse yes - ''; -} diff --git a/home/file/sway/module/Notification.conf b/home/file/sway/module/Notification.conf new file mode 100644 index 00000000..159e88f7 --- /dev/null +++ b/home/file/sway/module/Notification.conf @@ -0,0 +1,5 @@ +# Show last notification. +bindsym --to-code $mod+shift+n exec makoctl restore + +# Hide all notifications. +bindsym --to-code $mod+n exec makoctl dismiss --all diff --git a/home/file/sway/module/Notification.nix b/home/file/sway/module/Notification.nix deleted file mode 100644 index 928e8fd1..00000000 --- a/home/file/sway/module/Notification.nix +++ /dev/null @@ -1,10 +0,0 @@ -{ ... }: -{ - text = '' - # Show last notification. - bindsym --to-code $mod+shift+n exec makoctl restore - - # Hide all notifications. - bindsym --to-code $mod+n exec makoctl dismiss --all - ''; -} diff --git a/home/file/sway/module/Resize.conf b/home/file/sway/module/Resize.conf new file mode 100644 index 00000000..04a74a17 --- /dev/null +++ b/home/file/sway/module/Resize.conf @@ -0,0 +1,4 @@ +bindsym --to-code $mod+j resize grow height 10px +bindsym --to-code $mod+k resize shrink height 10px +bindsym --to-code $mod+h resize shrink width 10px +bindsym --to-code $mod+l resize grow width 10px diff --git a/home/file/sway/module/Resize.nix b/home/file/sway/module/Resize.nix deleted file mode 100644 index d26e8f77..00000000 --- a/home/file/sway/module/Resize.nix +++ /dev/null @@ -1,13 +0,0 @@ -{ ... }: -let - stepHorizontal = 10; - stepVertical = 10; -in -{ - text = '' - bindsym --to-code $mod+j resize grow height ${toString stepVertical}px - bindsym --to-code $mod+k resize shrink height ${toString stepVertical}px - bindsym --to-code $mod+h resize shrink width ${toString stepHorizontal}px - bindsym --to-code $mod+l resize grow width ${toString stepHorizontal}px - ''; -} diff --git a/home/file/sway/module/ScratchPad.conf b/home/file/sway/module/ScratchPad.conf new file mode 100644 index 00000000..73eb4af3 --- /dev/null +++ b/home/file/sway/module/ScratchPad.conf @@ -0,0 +1,48 @@ +# Sway has a "scratchpad", which is a bag of holding for windows. +# You can send windows there and get them back later. +# NOTE: Get id with `swaymsg -t get_tree`. + +# Show the next scratchpad window or hide the focused scratchpad window. +# If there are multiple scratchpad windows, this command cycles through them. +bindsym --to-code $mod+c scratchpad show +bindsym --to-code $mod+shift+C move scratchpad +bindsym --to-code $mod+shift+X exec swayscript scratchpad_kill + +# Fix for a goddamn Firefox WebRTC indicator. +for_window [app_id="firefox" title="Firefox — Sharing Indicator"] { + kill +} + +# NetworkManager. +for_window [app_id="nm-connection-editor"] { + move scratchpad + scratchpad show +} + +# Bluetooth. +for_window [app_id=".blueman-manager-wrapped"] { + move scratchpad + scratchpad show +} + +# Sound. +for_window [app_id="pavucontrol"] { + move scratchpad + scratchpad show +} + +# Android emulator controls. +for_window [title="Emulator" window_type="utility"] { + move scratchpad +} + +# Calculator. +for_window [app_id="org.gnome.Calculator"] { + move scratchpad + scratchpad show +} + +# JamesDsp. +for_window [title="JamesDSP for Linux"] { + move scratchpad +} diff --git a/home/file/sway/module/ScratchPad.nix b/home/file/sway/module/ScratchPad.nix deleted file mode 100644 index dd4496e7..00000000 --- a/home/file/sway/module/ScratchPad.nix +++ /dev/null @@ -1,53 +0,0 @@ -{ ... }: -{ - text = '' - # Sway has a "scratchpad", which is a bag of holding for windows. - # You can send windows there and get them back later. - # NOTE: Get id with `swaymsg -t get_tree`. - - # Show the next scratchpad window or hide the focused scratchpad window. - # If there are multiple scratchpad windows, this command cycles through them. - bindsym --to-code $mod+c scratchpad show - bindsym --to-code $mod+shift+C move scratchpad - bindsym --to-code $mod+shift+X exec swayscript scratchpad_kill - - # Fix for a goddamn Firefox WebRTC indicator. - for_window [app_id="firefox" title="Firefox — Sharing Indicator"] { - kill - } - - # NetworkManager. - for_window [app_id="nm-connection-editor"] { - move scratchpad - scratchpad show - } - - # Bluetooth. - for_window [app_id=".blueman-manager-wrapped"] { - move scratchpad - scratchpad show - } - - # Sound. - for_window [app_id="pavucontrol"] { - move scratchpad - scratchpad show - } - - # Android emulator controls. - for_window [title="Emulator" window_type="utility"] { - move scratchpad - } - - # Calculator. - for_window [app_id="org.gnome.Calculator"] { - move scratchpad - scratchpad show - } - - # JamesDsp. - for_window [title="JamesDSP for Linux"] { - move scratchpad - } - ''; -} diff --git a/home/file/sway/module/Screenshot.conf b/home/file/sway/module/Screenshot.conf new file mode 100644 index 00000000..8dd39818 --- /dev/null +++ b/home/file/sway/module/Screenshot.conf @@ -0,0 +1,5 @@ +bindsym --to-code $mod+y exec @FullscreenScreenshot@/bin/FullscreenScreenshot} +bindsym --to-code $mod+shift+y exec @FullscreenRecording@/bin/FullscreenRecording} + +bindsym --to-code $mod+v exec @SelectScreenshot@/bin/SelectScreenshot} +bindsym --to-code $mod+shift+v exec @SelectRecording@/bin/SelectRecording} diff --git a/home/file/sway/module/Screenshot.nix b/home/file/sway/module/Screenshot.nix deleted file mode 100644 index 984c7041..00000000 --- a/home/file/sway/module/Screenshot.nix +++ /dev/null @@ -1,165 +0,0 @@ -{ - __findFile, - config, - lib, - pkgs, - ... -}: -let - codec = "libsvtav1"; - color = config.module.style.color; - container = "mp4"; - format = "%Y-%m-%d_%H-%M-%S"; - framerate = 10; - opacity = "26"; - pixfmt = "yuv420p10le"; - selection = "slurp -d -b ${color.bg.light}${opacity} -c ${color.fg.light} -w 0 -s 00000000"; -in -{ - text = - let - notifyStart = ''swayscript notify_short''; - notifyEnd = ''swayscript notify_long''; - picEdit = ''swappy -f - -o -''; - picFull = ''-o $(swaymsg -t get_outputs | jq -r ".[] | select(.focused) | .name") -''; - picPrepFile = prepFile "\${XDG_PICTURES_DIR[0]}" "png"; - picRefLatestFile = refLatestFile "png"; - picSelected = ''-g "''${scrSelection}" -''; - picToBuffer = ''wl-copy -t image/png''; - picToFile = ''tee "''${scrFile}"''; - screenshot = ''grim''; - updateWaybar = ''{ pkill -RTMIN+4 waybar; } & disown''; # NOTE: Might need to add a delay here if it becomes inconsistent one day. - vidFull = ''-o $(swaymsg -t get_outputs | jq -r ".[] | select(.focused) | .name") -''; - vidPrepFile = prepFile "\${XDG_VIDEOS_DIR[0]}" container; - vidRefLatestFile = refLatestFile container; - vidSelected = ''--geometry "''${scrSelection}"''; - vidStop = ''pkill -SIGINT wf-recorder''; - - prepFile = path: ext: '' - # Focused app id by default. - curWindow=$(parse_snake $(swaymsg -t get_tree | jq '.. | select(.type?) | select(.focused==true) | .app_id')) - - # If no id (i.e. xwayland), then use a name (title). - [[ "''${curWindow}" = "null" ]] && curWindow=$(parse_snake $(swaymsg -t get_tree | jq '.. | select(.type?) | select(.focused==true) | .name')) - - # If no app in focus, use "unknown" dir. - [[ "''${curWindow}" =~ ^[0-9]+$ ]] && curWindow="unknown" - - # Prepare dir and file path. - scrPath="${path}" - scrDir="${path}/''${curWindow}" - mkdir -p "''${scrDir}" - scrName="$(date +${format}).${ext}" - scrFile="''${scrDir}/''${scrName}" - scrLatestRef="./''${curWindow}/''${scrName}" - ''; - - refLatestFile = ext: '' - scrLatest="''${scrPath}/Latest.${ext}" - rm "''${scrLatest}" - ln -s "''${scrLatestRef}" "''${scrLatest}" - ''; - - getSelection = '' - scrSelection=$(${selection}) - [[ -n "''${scrSelection}" ]] || exit - ''; - - getTransform = '' - scrTransform="$(swaymsg -t get_outputs | jq -r '.[] | select(.focused) | .transform')" - [[ "''${scrTransform}" = "normal" ]] && scrTransform="" - ''; - - vidStart = '' - wf-recorder \ - --no-damage \ - --codec ${codec} \ - --file "''${scrFile}" \ - --framerate ${toString framerate} \ - --pixel-format ${pixfmt} \ - ''; - - vidMuxAudio = '' - ffmpeg \ - -f lavfi \ - -i anullsrc=channel_layout=stereo:sample_rate=44100 \ - -i "''${scrFile}" \ - -c:v copy \ - -c:a libopus \ - -shortest \ - -f ${container} \ - "''${scrFile}_" \ - && mv "''${scrFile}_" "''${scrFile}" \ - || rm "''${scrFile}_" - ''; - - vidTransform = '' - if [[ -n "''${scrTransform}" ]]; then - ffmpeg \ - -display_rotation ''${scrTransform} \ - -i "''${scrFile}" \ - -c copy \ - -f ${container} \ - "''${scrFile}_" \ - && mv "''${scrFile}_" "''${scrFile}" \ - || rm "''${scrFile}_" - fi - ''; - - SelectRecording = pkgs.writeShellScriptBin "SelectRecording" '' - ${vidStop} || { - ${getSelection} - ${getTransform} - ${vidPrepFile} - ${notifyStart} - ${updateWaybar} - ${vidStart} ${vidSelected} - ${notifyEnd} - ${updateWaybar} - ${vidMuxAudio} - ${vidTransform} - ${vidRefLatestFile} - }; - ''; - - FullscreenRecording = pkgs.writeShellScriptBin "FullscreenRecording" '' - ${vidStop} || { - ${getTransform} - ${vidPrepFile} - ${notifyStart} - ${updateWaybar} - ${vidStart} ${vidFull} - ${notifyEnd} - ${updateWaybar} - ${vidMuxAudio} - ${vidTransform} - ${vidRefLatestFile} - }; - ''; - - FullscreenScreenshot = pkgs.writeShellScriptBin "FullscreenScreenshot" '' - ${notifyEnd} - ${picPrepFile} - - ${screenshot} ${picFull} | ${picToFile} | ${picToBuffer} - ${picRefLatestFile} - ''; - - SelectScreenshot = pkgs.writeShellScriptBin "SelectScreenshot" '' - ${getSelection} - ${notifyStart} - ${picPrepFile} - - ${screenshot} ${picSelected} | ${picEdit} | ${picToFile} | ${picToBuffer} - ${notifyEnd} - ${picRefLatestFile} - ''; - in - '' - bindsym --to-code $mod+y exec ${lib.getExe FullscreenScreenshot} - bindsym --to-code $mod+shift+y exec ${lib.getExe FullscreenRecording} - - bindsym --to-code $mod+v exec ${lib.getExe SelectScreenshot} - bindsym --to-code $mod+shift+v exec ${lib.getExe SelectRecording} - ''; -} diff --git a/home/file/sway/module/Session.nix b/home/file/sway/module/Session.nix deleted file mode 100644 index 3f174eb5..00000000 --- a/home/file/sway/module/Session.nix +++ /dev/null @@ -1,10 +0,0 @@ -{ config, ... }: -let - lock = "swaylock -f -F -c 000000 -k --font \"${config.module.style.font.serif.name}\" --font-size ${toString config.module.style.font.size.desktop}"; -in -{ - text = '' - bindsym --to-code $mod+z exec '_twice 1 ${lock}' - bindsym --to-code $mod+Shift+Z exec _twice 1 bash -c '${lock}; systemctl suspend -i' - ''; -} diff --git a/home/file/sway/module/Sound.conf b/home/file/sway/module/Sound.conf new file mode 100644 index 00000000..36fc1444 --- /dev/null +++ b/home/file/sway/module/Sound.conf @@ -0,0 +1,13 @@ +bindsym XF86AudioRaiseVolume exec 'pactl set-sink-volume @DEFAULT_SINK@ +5%' +bindsym XF86AudioLowerVolume exec 'pactl set-sink-volume @DEFAULT_SINK@ -5%' +bindsym XF86AudioMute exec 'pactl set-sink-mute @DEFAULT_SINK@ toggle' +bindsym XF86AudioMicMute exec 'pactl set-source-mute @DEFAULT_SOURCE@ toggle' + +bindsym XF86AudioPlay exec 'playerctl play-pause' +bindsym XF86AudioPause exec 'playerctl pause' +bindsym XF86AudioStop exec 'playerctl stop' +bindsym XF86AudioNext exec 'playerctl next' +bindsym XF86AudioPrev exec 'playerctl previous' +bindsym XF86Forward exec 'playerctl position 10+' +bindsym XF86Back exec 'playerctl position 10-' +bindsym XF86Eject exec 'swayscript sound_output_cycle' diff --git a/home/file/sway/module/Sound.nix b/home/file/sway/module/Sound.nix deleted file mode 100644 index 90a64883..00000000 --- a/home/file/sway/module/Sound.nix +++ /dev/null @@ -1,22 +0,0 @@ -{ ... }: -let - step_music = 10; - step_volume = 5; -in -{ - text = '' - bindsym XF86AudioRaiseVolume exec 'pactl set-sink-volume @DEFAULT_SINK@ +${toString step_volume}%' - bindsym XF86AudioLowerVolume exec 'pactl set-sink-volume @DEFAULT_SINK@ -${toString step_volume}%' - bindsym XF86AudioMute exec 'pactl set-sink-mute @DEFAULT_SINK@ toggle' - bindsym XF86AudioMicMute exec 'pactl set-source-mute @DEFAULT_SOURCE@ toggle' - - bindsym XF86AudioPlay exec 'playerctl play-pause' - bindsym XF86AudioPause exec 'playerctl pause' - bindsym XF86AudioStop exec 'playerctl stop' - bindsym XF86AudioNext exec 'playerctl next' - bindsym XF86AudioPrev exec 'playerctl previous' - bindsym XF86Forward exec 'playerctl position ${toString step_music}+' - bindsym XF86Back exec 'playerctl position ${toString step_music}-' - bindsym XF86Eject exec 'swayscript sound_output_cycle' - ''; -} diff --git a/home/file/sway/module/Style.conf b/home/file/sway/module/Style.conf new file mode 100644 index 00000000..15a5904b --- /dev/null +++ b/home/file/sway/module/Style.conf @@ -0,0 +1,6 @@ +output * bg @wallpaper@ fill +client.focused "#@accent@" "#@accent@" "#@fg@" "#@accent@" "#@accent@" +client.focused_inactive "#@border@" "#@border@" "#@fg@" "#@border@" "#@border@" +client.unfocused "#@border@" "#@border@" "#@fg@" "#@border@" "#@border@" +client.urgent "#@border@" "#@border@" "#@fg@" "#@border@" "#@border@" +client.placeholder "#@border@" "#@border@" "#@fg@" "#@border@" "#@border@" diff --git a/home/file/sway/module/Style.nix b/home/file/sway/module/Style.nix deleted file mode 100644 index 04e92d85..00000000 --- a/home/file/sway/module/Style.nix +++ /dev/null @@ -1,17 +0,0 @@ -{ config, ... }: -let - accent = config.module.style.color.accent + alpha; - alpha = config.module.style.opacity.hex; - border = config.module.style.color.border + alpha; - fg = config.module.style.color.fg.light; -in -{ - text = '' - output * bg ${config.module.wallpaper.path} fill - client.focused "#${accent}" "#${accent}" "#${fg}" "#${accent}" "#${accent}" - client.focused_inactive "#${border}" "#${border}" "#${fg}" "#${border}" "#${border}" - client.unfocused "#${border}" "#${border}" "#${fg}" "#${border}" "#${border}" - client.urgent "#${border}" "#${border}" "#${fg}" "#${border}" "#${border}" - client.placeholder "#${border}" "#${border}" "#${fg}" "#${border}" "#${border}" - ''; -} diff --git a/home/file/sway/module/System.conf b/home/file/sway/module/System.conf new file mode 100644 index 00000000..d98bd3bf --- /dev/null +++ b/home/file/sway/module/System.conf @@ -0,0 +1,17 @@ +bindsym $sysmod input * xkb_switch_layout 0 +bindsym --to-code $sysmod+a exec 'swayscript network' +bindsym --to-code $sysmod+c exec 'systemctl reboot -i' +bindsym --to-code $sysmod+d exec 'swayscript dnd' +bindsym --to-code $sysmod+g exec 'swayscript gaming' +bindsym --to-code $sysmod+l exec 'powerlimit toggle' +bindsym --to-code $sysmod+m exec 'swayscript monitor' +bindsym --to-code $sysmod+p exec 'powersave toggle' +bindsym --to-code $sysmod+r exec 'swayscript reload' +bindsym --to-code $sysmod+v exec 'swayscript vpn' +bindsym --to-code $sysmod+x exec 'systemctl poweroff -i' +bindsym --to-code $sysmod+z exec 'systemctl suspend -i' + +bindsym --to-code $sysmod+w exec light -A 5 +bindsym XF86MonBrightnessUp exec light -A 5 +bindsym --to-code $sysmod+s exec light -U 5 +bindsym XF86MonBrightnessDown exec light -U 5 diff --git a/home/file/sway/module/System.nix b/home/file/sway/module/System.nix deleted file mode 100644 index e536b8bd..00000000 --- a/home/file/sway/module/System.nix +++ /dev/null @@ -1,25 +0,0 @@ -{ ... }: -let - brstep = 5; -in -{ - text = '' - bindsym $sysmod input * xkb_switch_layout 0 - bindsym --to-code $sysmod+a exec 'swayscript network' - bindsym --to-code $sysmod+c exec 'systemctl reboot -i' - bindsym --to-code $sysmod+d exec 'swayscript dnd' - bindsym --to-code $sysmod+g exec 'swayscript gaming' - bindsym --to-code $sysmod+l exec 'powerlimit toggle' - bindsym --to-code $sysmod+m exec 'swayscript monitor' - bindsym --to-code $sysmod+p exec 'powersave toggle' - bindsym --to-code $sysmod+r exec 'swayscript reload' - bindsym --to-code $sysmod+v exec 'swayscript vpn' - bindsym --to-code $sysmod+x exec 'systemctl poweroff -i' - bindsym --to-code $sysmod+z exec 'systemctl suspend -i' - - bindsym --to-code $sysmod+w exec light -A ${toString brstep} - bindsym XF86MonBrightnessUp exec light -A ${toString brstep} - bindsym --to-code $sysmod+s exec light -U ${toString brstep} - bindsym XF86MonBrightnessDown exec light -U ${toString brstep} - ''; -} diff --git a/home/file/sway/module/Terminal.conf b/home/file/sway/module/Terminal.conf new file mode 100644 index 00000000..47b57751 --- /dev/null +++ b/home/file/sway/module/Terminal.conf @@ -0,0 +1,3 @@ +set $term foot + +bindsym --to-code $mod+Escape exec $term -e bash -i -c "tmux new-session -A -s $USER; bash -i" diff --git a/home/file/sway/module/Terminal.nix b/home/file/sway/module/Terminal.nix deleted file mode 100644 index c7cd3574..00000000 --- a/home/file/sway/module/Terminal.nix +++ /dev/null @@ -1,8 +0,0 @@ -{ ... }: -{ - text = '' - set $term foot - - bindsym --to-code $mod+Escape exec $term -e bash -i -c "tmux new-session -A -s $USER; bash -i" - ''; -} diff --git a/home/file/sway/module/Tiling.conf b/home/file/sway/module/Tiling.conf new file mode 100644 index 00000000..2f1a150f --- /dev/null +++ b/home/file/sway/module/Tiling.conf @@ -0,0 +1,31 @@ +# Toggle tiling. +bindsym --to-code $mod+shift+f floating toggle + +# Swap focus between the tiling area and the floating area +bindsym --to-code $mod+r focus mode_toggle + +# Split directions. +bindsym --to-code $mod+backslash splith +bindsym --to-code $mod+minus splitv + +# Switch the current container between different layout styles. +bindsym --to-code $mod+Tab layout toggle split tabbed + +# Fullscreen. +bindsym --to-code $mod+f fullscreen + +# Drag floating windows by holding down $mod and left mouse button. +# Resize them with right mouse button + $mod. +# Despite the name, also works for non-floating windows. +# Change normal to inverse to use left mouse button for resizing and right +# mouse button for dragging. +floating_modifier $mod normal + +# Kill focused window. +bindsym --to-code $mod+x kill + +# Add gaps. +gaps inner @windowGap@ + +# Launch everything tiled. +# for_window [all] floating disable diff --git a/home/file/sway/module/Tiling.nix b/home/file/sway/module/Tiling.nix deleted file mode 100644 index a8f57acc..00000000 --- a/home/file/sway/module/Tiling.nix +++ /dev/null @@ -1,36 +0,0 @@ -{ config, ... }: -{ - text = '' - # Toggle tiling. - bindsym --to-code $mod+shift+f floating toggle - - # Swap focus between the tiling area and the floating area - bindsym --to-code $mod+r focus mode_toggle - - # Split directions. - bindsym --to-code $mod+backslash splith - bindsym --to-code $mod+minus splitv - - # Switch the current container between different layout styles. - bindsym --to-code $mod+Tab layout toggle split tabbed - - # Fullscreen. - bindsym --to-code $mod+f fullscreen - - # Drag floating windows by holding down $mod and left mouse button. - # Resize them with right mouse button + $mod. - # Despite the name, also works for non-floating windows. - # Change normal to inverse to use left mouse button for resizing and right - # mouse button for dragging. - floating_modifier $mod normal - - # Kill focused window. - bindsym --to-code $mod+x kill - - # Add gaps. - gaps inner ${toString config.module.style.window.gap} - - # Launch everything tiled. - # for_window [all] floating disable - ''; -} diff --git a/home/file/sway/module/TitleBar.conf b/home/file/sway/module/TitleBar.conf new file mode 100644 index 00000000..a61bf32c --- /dev/null +++ b/home/file/sway/module/TitleBar.conf @@ -0,0 +1,5 @@ +# Disable title bar. +default_border pixel @borderSize@ +default_floating_border pixel @borderSize@ +titlebar_padding 1 +titlebar_border_thickness 0 diff --git a/home/file/sway/module/TitleBar.nix b/home/file/sway/module/TitleBar.nix deleted file mode 100644 index a6397380..00000000 --- a/home/file/sway/module/TitleBar.nix +++ /dev/null @@ -1,13 +0,0 @@ -{ config, ... }: -let - borderSize = toString config.module.style.window.border; -in -{ - text = '' - # Disable title bar. - default_border pixel ${borderSize} - default_floating_border pixel ${borderSize} - titlebar_padding 1 - titlebar_border_thickness 0 - ''; -} diff --git a/home/file/sway/module/Waybar.conf b/home/file/sway/module/Waybar.conf new file mode 100644 index 00000000..3cf46176 --- /dev/null +++ b/home/file/sway/module/Waybar.conf @@ -0,0 +1,2 @@ +bindsym --to-code $mod+shift+r exec 'pkill waybar || exec waybar' +exec waybar diff --git a/home/file/sway/module/Waybar.nix b/home/file/sway/module/Waybar.nix deleted file mode 100644 index e895e76f..00000000 --- a/home/file/sway/module/Waybar.nix +++ /dev/null @@ -1,7 +0,0 @@ -{ ... }: -{ - text = '' - bindsym --to-code $mod+shift+r exec 'pkill waybar || exec waybar' - exec waybar - ''; -} diff --git a/home/file/sway/module/Workspace.conf b/home/file/sway/module/Workspace.conf new file mode 100644 index 00000000..9bece5d0 --- /dev/null +++ b/home/file/sway/module/Workspace.conf @@ -0,0 +1,33 @@ +# Switch to workspace. +bindsym --to-code $mod+1 workspace number 1 +bindsym --to-code $mod+2 workspace number 2 +bindsym --to-code $mod+3 workspace number 3 +bindsym --to-code $mod+4 workspace number 4 +bindsym --to-code $mod+5 workspace number 5 +bindsym --to-code $mod+6 workspace number 6 +bindsym --to-code $mod+7 workspace number 7 +bindsym --to-code $mod+8 workspace number 8 +bindsym --to-code $mod+9 workspace number 9 +bindsym --to-code $mod+0 workspace number 10 + +# Move focused container to workspace. +bindsym --to-code $mod+Shift+1 move container to workspace number 1 +bindsym --to-code $mod+Shift+2 move container to workspace number 2 +bindsym --to-code $mod+Shift+3 move container to workspace number 3 +bindsym --to-code $mod+Shift+4 move container to workspace number 4 +bindsym --to-code $mod+Shift+5 move container to workspace number 5 +bindsym --to-code $mod+Shift+6 move container to workspace number 6 +bindsym --to-code $mod+Shift+7 move container to workspace number 7 +bindsym --to-code $mod+Shift+8 move container to workspace number 8 +bindsym --to-code $mod+Shift+9 move container to workspace number 9 +bindsym --to-code $mod+Shift+0 move container to workspace number 10 +# Note: workspaces can have any name you want, not just numbers. +# We just use 1-10 as the default. + +# Switch left-right. +bindsym --to-code $mod+e workspace next +bindsym --to-code $mod+q workspace prev + +# Move left-right. +bindsym --to-code $mod+Shift+e move container to workspace next +bindsym --to-code $mod+Shift+q move container to workspace prev diff --git a/home/file/sway/module/Workspace.nix b/home/file/sway/module/Workspace.nix deleted file mode 100644 index da9e3937..00000000 --- a/home/file/sway/module/Workspace.nix +++ /dev/null @@ -1,38 +0,0 @@ -{ ... }: -{ - text = '' - # Switch to workspace. - bindsym --to-code $mod+1 workspace number 1 - bindsym --to-code $mod+2 workspace number 2 - bindsym --to-code $mod+3 workspace number 3 - bindsym --to-code $mod+4 workspace number 4 - bindsym --to-code $mod+5 workspace number 5 - bindsym --to-code $mod+6 workspace number 6 - bindsym --to-code $mod+7 workspace number 7 - bindsym --to-code $mod+8 workspace number 8 - bindsym --to-code $mod+9 workspace number 9 - bindsym --to-code $mod+0 workspace number 10 - - # Move focused container to workspace. - bindsym --to-code $mod+Shift+1 move container to workspace number 1 - bindsym --to-code $mod+Shift+2 move container to workspace number 2 - bindsym --to-code $mod+Shift+3 move container to workspace number 3 - bindsym --to-code $mod+Shift+4 move container to workspace number 4 - bindsym --to-code $mod+Shift+5 move container to workspace number 5 - bindsym --to-code $mod+Shift+6 move container to workspace number 6 - bindsym --to-code $mod+Shift+7 move container to workspace number 7 - bindsym --to-code $mod+Shift+8 move container to workspace number 8 - bindsym --to-code $mod+Shift+9 move container to workspace number 9 - bindsym --to-code $mod+Shift+0 move container to workspace number 10 - # Note: workspaces can have any name you want, not just numbers. - # We just use 1-10 as the default. - - # Switch left-right. - bindsym --to-code $mod+e workspace next - bindsym --to-code $mod+q workspace prev - - # Move left-right. - bindsym --to-code $mod+Shift+e move container to workspace next - bindsym --to-code $mod+Shift+q move container to workspace prev - ''; -}