diff --git a/hosts/mrmeeseeks/home-config.nix b/hosts/mrmeeseeks/home-config.nix index e180376..d00ab09 100644 --- a/hosts/mrmeeseeks/home-config.nix +++ b/hosts/mrmeeseeks/home-config.nix @@ -1,7 +1,10 @@ -{ ... }: { +{ inputs, ... }: { config.modules = { application = { - gnupg.enable = true; + gnupg = { + enable = true; + enableSshSupport = true; + }; zathura.enable = true; foot.enable = true; }; @@ -11,7 +14,10 @@ git.enable = true; neovim.enable = true; starship.enable = true; - tmux.enable = true; + tmux = { + enable = true; + extraConfig = inputs.nix-private.tmux.personal; + }; utils.enable = true; vifm.enable = true; zsh.enable = true; diff --git a/hosts/work/home-config.nix b/hosts/work/home-config.nix index 0155435..733c542 100644 --- a/hosts/work/home-config.nix +++ b/hosts/work/home-config.nix @@ -38,8 +38,7 @@ laptop = true; gpuThermal.enable = false; cpuThermal = { - hwmonPathAbs = "/sys/devices/platform/coretemp.0/hwmon/"; - inputFilename = "temp1_input"; + thermalZone = 9; }; }; xdg.useDistributionPortals = true; diff --git a/modules/home-manager/application/gnupg/default.nix b/modules/home-manager/application/gnupg/default.nix index 53a24f1..62a2aab 100644 --- a/modules/home-manager/application/gnupg/default.nix +++ b/modules/home-manager/application/gnupg/default.nix @@ -46,12 +46,6 @@ in noAllowExternalCache = true; }; - home.sessionVariablesExtra = lib.mkIf cfg.enableSshSupport '' - if [[ -z "''${SSH_AUTH_SOCK}" ]]; then - export SSH_AUTH_SOCK="$(${config.programs.gpg.package}/bin/gpgconf --list-dirs agent-ssh-socket)" - fi - ''; - services.ssh-agent.enable = if cfg.enableSshSupport then false else true; programs.password-store = { enable = cfg.pass; diff --git a/modules/home-manager/cli/neovim/default.nix b/modules/home-manager/cli/neovim/default.nix index ee3302e..9d928b1 100644 --- a/modules/home-manager/cli/neovim/default.nix +++ b/modules/home-manager/cli/neovim/default.nix @@ -65,7 +65,7 @@ in python3Packages.python-lsp-server shellcheck - terraform-lsp + tofu-ls tflint vscode-langservers-extracted yaml-language-server @@ -120,7 +120,7 @@ in { plugin = gitsigns-nvim; type = "lua"; - config = (builtins.readFile ./files/plugins/luasnip.lua); + config = (builtins.readFile ./files/plugins/gitsign.lua); } { plugin = indent-blankline-nvim; @@ -205,7 +205,10 @@ in type = "lua"; config = ( builtins.readFile ./files/plugins/nvim-k8s-lsp.lua ); } - vim-helm + { + plugin = helm-ls-nvim; + type = "lua"; + } ]; }; }; diff --git a/modules/home-manager/cli/neovim/files/keybindings.lua b/modules/home-manager/cli/neovim/files/keybindings.lua index aeaabe3..b0d8b13 100644 --- a/modules/home-manager/cli/neovim/files/keybindings.lua +++ b/modules/home-manager/cli/neovim/files/keybindings.lua @@ -1,6 +1,15 @@ +local opts = { noremap = true, silent = true} + +vim.api.nvim_set_keymap('n', '/', ':nohlsearch', opts) +vim.api.nvim_set_keymap('n', 'l', ':set list!', {silent = true}) + -- clear search vim.keymap.set('n', 'l', ':nohlsearch', { desc = 'Clear search', remap = true, silent = true }) +-- Move tabs with \[ and \] +vim.api.nvim_set_keymap('n', ']', ':tabnext', opts) +vim.api.nvim_set_keymap('n', '[', ':tabprev', opts) + -- Switch between windows. vim.keymap.set('n', '', 'h', { desc = 'Move to the left window', remap = true }) vim.keymap.set('n', '', 'j', { desc = 'Move to the bottom window', remap = true }) @@ -19,31 +28,3 @@ vim.keymap.set('n', 'tn', ':tabnew', { desc = "Tab [n]ew", remap = t -- Show all caracters vim.keymap.set('n', 'l', ':set list!', { desc = "Show a[l]l caraters", remap = true, silent = true}) - --- neotree --- ------- -vim.keymap.set('n', 'nc', ':Neotree close', {desc='Neotree [c]lose'}) -vim.keymap.set('n', 'nf', ':Neotree focus filesystem', {desc='Neotree [f]ocus'}) -vim.keymap.set('n', 'nb', ':Neotree focus buffers', {desc='Neotree Nvim [b]uffers'}) -vim.keymap.set('n', 'ng', ':Neotree focus git_status', {desc='Neotree [g]it status'}) - --- fzf-lua --- ------ -vim.keymap.set('n', 'fb', function() require('fzf-lua').buffers() end, {desc='open [b]uffers'}) -vim.keymap.set('n', 'ff', function() require('fzf-lua').files() end, {desc='[r]esume last command'}) -vim.keymap.set('n', 'fr', function() require('fzf-lua').files() end, {desc='[f]iles'}) - --- git related keymaps -vim.keymap.set('n', 'fgb', function() require('fzf-lua').git_branches() end, {desc='Git [b]ranches'}) -vim.keymap.set('n', 'fgc', function() require('fzf-lua').git_commits() end, {desc='Git [c]ommits'}) -vim.keymap.set('n', 'fgC', function() require('fzf-lua').git_bcommits() end, {desc='Git current buffer [C]ommits'}) -vim.keymap.set('n', 'fgf', function() require('fzf-lua').git_files() end, {desc='Git [f]iles'}) -vim.keymap.set('n', 'fgs', function() require('fzf-lua').git_stash() end, {desc='Git [s]tash'}) -vim.keymap.set('n', 'fgS', function() require('fzf-lua').git_status() end, {desc='Git [S]tash'}) - --- grep related keymaps -vim.keymap.set('n', 'fGb', function() require('fzf-lua').grep_curbuf() end, {desc='grep in current [b]uffer'}) -vim.keymap.set('n', 'fGc', function() require('fzf-lua').grep_cword() end, {desc='grep word under the [c]ursor'}) -vim.keymap.set('n', 'fGg', function() require('fzf-lua').grep() end, {desc='[g]rep'}) -vim.keymap.set('n', 'fGl', function() require('fzf-lua').live_grep() end, {desc='[l]ive grep'}) -vim.keymap.set('n', 'fGr', function() require('fzf-lua').grep_last() end, {desc='[r]erun last grep'}) diff --git a/modules/home-manager/cli/neovim/files/lsp/helm.lua b/modules/home-manager/cli/neovim/files/lsp/helm.lua index 8086a4a..29e9e11 100644 --- a/modules/home-manager/cli/neovim/files/lsp/helm.lua +++ b/modules/home-manager/cli/neovim/files/lsp/helm.lua @@ -1,7 +1,8 @@ return { cmd = { 'helm_ls', 'serve' }, - filetypes = { 'helm' }, - root_markers = { 'Chart.yaml' }, + filetypes = { 'helm', 'yaml.helm-values' }, + single_file_support = true, + root_markers = { 'values.yaml', 'Chart.yaml' }, capabilities = { workspace = { didChangeWatchedFiles = { @@ -18,9 +19,7 @@ return { showdiagnosticsdirectly = false, path = "yaml-language-server", config = { - schemas = { - kubernetes = "template/**", - }, + schemas = {}, completion = true, hover = true, } diff --git a/modules/home-manager/cli/neovim/files/lsp/terraformls.lua b/modules/home-manager/cli/neovim/files/lsp/tofuls.lua similarity index 73% rename from modules/home-manager/cli/neovim/files/lsp/terraformls.lua rename to modules/home-manager/cli/neovim/files/lsp/tofuls.lua index 4a875c3..8eba7d0 100644 --- a/modules/home-manager/cli/neovim/files/lsp/terraformls.lua +++ b/modules/home-manager/cli/neovim/files/lsp/tofuls.lua @@ -1,5 +1,5 @@ return { - cmd = { 'terraform-ls', 'serve' }, + cmd = { 'tofu-ls', 'serve' }, filetypes = { 'terraform', 'terraform-vars' }, root_markers = { '.terraform', '.git' }, } diff --git a/modules/home-manager/cli/neovim/files/options.lua b/modules/home-manager/cli/neovim/files/options.lua index b683e0a..37fcdcb 100644 --- a/modules/home-manager/cli/neovim/files/options.lua +++ b/modules/home-manager/cli/neovim/files/options.lua @@ -52,7 +52,7 @@ vim.opt.wildmode = 'lastused:full,list' -- enhance menu vim.opt.pumheight = 10 vim.opt.pumwidth = 50 vim.opt.pumblend = 10 - +vim.o.winborder = 'none' -- manage line break smartly vim.opt.wrap = true vim.opt.breakindent = true @@ -103,24 +103,13 @@ vim.opt.wildignore = { '*.sw?' } --- Key biding --- " ---------- -local opts = { noremap = true, silent = true} - -vim.api.nvim_set_keymap('n', '/', ':nohlsearch', opts) - --- Move tabs with \[ and \] -vim.api.nvim_set_keymap('n', ']', ':tabnext', opts) -vim.api.nvim_set_keymap('n', '[', ':tabprev', opts) -vim.api.nvim_set_keymap('n', 'l', ':set list!', {silent = true}) - -- disable lsplog -- This is not usefull on a daily basis and should positively impact performance vim.lsp.set_log_level("off") -- define a timeout for match parens -vim.g.matchparen_timeout = 2 -vim.g.matchparen_insert_timeout = 2 +vim.g.matchparen_timeout = 10 +vim.g.matchparen_insert_timeout = 10 -- activate virtual lines for diagnistics -- no more plugins needed @@ -134,3 +123,73 @@ vim.diagnostic.config({ -- }, signs = { text = { [x.ERROR] = "󰅙", [x.WARN] = "", [x.INFO] = "󰋼", [x.HINT] = "󰌵" } }, }) + +-- LSP +vim.api.nvim_create_autocmd("LspAttach", { + group = vim.api.nvim_create_augroup("UserLspConfig", {}), + callback = function(ev) + vim.bo[ev.buf].omnifunc = "v:lua.vim.lsp.omnifunc" + + local opts = { buffer = ev.buf } + local client = vim.lsp.get_client_by_id(ev.data.client_id) + local bufnr = ev.buf + local function desc(description) + return { noremap = true, silent = true, buffer = bufnr, desc = description } + end + + vim.keymap.set("n", "gD", vim.lsp.buf.declaration, { buffer = ev.buf, desc = "Go to [D]eclaration" }) + vim.keymap.set("n", "gd", vim.lsp.buf.definition, { buffer = ev.buf, desc = "Go to [d]efinition" }) + vim.keymap.set("n", "gi", vim.lsp.buf.implementation, { buffer = ev.buf, desc = "Go to [i]mplementation" }) + vim.keymap.set("n", "gr", vim.lsp.buf.references, { buffer = ev.buf, desc = "Go to [r]eferences" }) + + vim.keymap.set( + "n", + "K", + function() + vim.lsp.buf.hover + { border = "rounded", max_width = 250 } + end, + opts) + + vim.keymap.set( + "n", + "", + function() + vim.lsp.buf.signature_help + { border = "rounded", max_width = 250 } + end, + {buffer = ev.buf, desc = "Signature help"} + ) + + vim.keymap.set("n", "wa", vim.lsp.buf.add_workspace_folder, opts) + vim.keymap.set("n", "wr", vim.lsp.buf.remove_workspace_folder, opts) + + vim.keymap.set( + "n", + "wl", + function() + print(vim.inspect(vim.lsp.buf.list_workspace_folders())) + end, + opts + ) + + vim.keymap.set("n", "D", vim.lsp.buf.type_definition, { buffer = ev.buf, desc = "Type [D]efinition" }) + vim.keymap.set("n", "rn", vim.lsp.buf.rename, { buffer = ev.buf, desc = "LSP [r]e[n]ame" }) + vim.keymap.set("n", "ca", vim.lsp.buf.code_action, { buffer = ev.buf, desc = "Show [c]ode [a]ction"}) + + vim.keymap.set( + "n", + "F", + function() + require("conform").format({ bufnr = bufnr }) + end, + { buffer = ev.buf, desc = "[F]ormat file" } + ) + + if client.server_capabilities.inlayHintProvider then + vim.keymap.set("n", "h", function() + vim.lsp.inlay_hint.enable(not vim.lsp.inlay_hint.is_enabled()) + end, desc("LSP toggle inlay [h]ints")) + end + end, +}) diff --git a/modules/home-manager/cli/neovim/files/plugins/luasnip.lua b/modules/home-manager/cli/neovim/files/plugins/gitsign.lua similarity index 100% rename from modules/home-manager/cli/neovim/files/plugins/luasnip.lua rename to modules/home-manager/cli/neovim/files/plugins/gitsign.lua diff --git a/modules/home-manager/cli/neovim/files/plugins/neotree.lua b/modules/home-manager/cli/neovim/files/plugins/neotree.lua index d1fd640..27d8aff 100644 --- a/modules/home-manager/cli/neovim/files/plugins/neotree.lua +++ b/modules/home-manager/cli/neovim/files/plugins/neotree.lua @@ -18,3 +18,8 @@ neotree.setup({ }, } }) + +vim.keymap.set('n', 'nc', ':Neotree close', {desc='Neotree [c]lose'}) +vim.keymap.set('n', 'nf', ':Neotree focus filesystem', {desc='Neotree [f]ocus'}) +vim.keymap.set('n', 'nb', ':Neotree focus buffers', {desc='Neotree Nvim [b]uffers'}) +vim.keymap.set('n', 'ng', ':Neotree focus git_status', {desc='Neotree [g]it status'}) diff --git a/modules/home-manager/cli/neovim/files/plugins/nvim-k8s-lsp.lua b/modules/home-manager/cli/neovim/files/plugins/nvim-k8s-lsp.lua index a2176c6..400c8a1 100644 --- a/modules/home-manager/cli/neovim/files/plugins/nvim-k8s-lsp.lua +++ b/modules/home-manager/cli/neovim/files/plugins/nvim-k8s-lsp.lua @@ -1,6 +1,6 @@ require("nvim-k8s-lsp").setup({ - kubernetes_version = "v1.32.2", + kubernetes_version = "v1.32.8", integrations = { - lualine = false, + lualine = true, } }) diff --git a/modules/home-manager/desktop/sway/default.nix b/modules/home-manager/desktop/sway/default.nix index 4f53efa..d8fa2ff 100644 --- a/modules/home-manager/desktop/sway/default.nix +++ b/modules/home-manager/desktop/sway/default.nix @@ -46,6 +46,24 @@ in }; }; + iconTheme = mkOption { + type = types.package; + default = pkgs.papirus-icon-theme; + description = ''Icon theme package to use''; + }; + + iconThemeName = mkOption { + type = types.str; + default = "Papirus Dark"; + description = ''Icon theme variant to use''; + }; + + iconThemePathname = mkOption { + type = types.str; + default = "Papirus-Dark"; + description = ''Icon theme variant to use''; + }; + waybar = { laptop = mkOption { type = types.bool; @@ -56,8 +74,8 @@ in cpuThermal = { thermalZone = mkOption { - type = types.str; - default = ""; + type = types.int or null; + default = null; description = "CPU thermal hwmon thermal Zone"; }; @@ -107,6 +125,8 @@ in # emojione font-awesome grim + hicolor-icon-theme + jq lato liberation_ttf libertine @@ -117,6 +137,7 @@ in noto-fonts-cjk-sans slurp wl-clipboard + wl-screenrec xdg-utils ]; @@ -133,8 +154,8 @@ in package = pkgs.arc-theme; }; iconTheme = { - name = "Papirus Dark"; - package = pkgs.papirus-icon-theme; + name = cfg.iconThemeName; + package = cfg.iconTheme; }; font = { name = "Deja Vu Sans"; @@ -186,7 +207,7 @@ in xdg-desktop-portal-wlr xdg-desktop-portal-gtk ]; - xdgOpenUsePortal = true; + xdgOpenUsePortal = false; config = { sway = { default = [ diff --git a/modules/home-manager/desktop/sway/includes/files/screencapt.sh b/modules/home-manager/desktop/sway/includes/files/screencapt.sh new file mode 100755 index 0000000..353218d --- /dev/null +++ b/modules/home-manager/desktop/sway/includes/files/screencapt.sh @@ -0,0 +1,161 @@ +#!/usr/bin/env bash +set -eu -o pipefail + +APP_NAME="ScreenCapt" + +declare -A COMMAND +COMMAND=( + [screenshot]="grim" + [video]="wl-screenrec" +) +declare -A ICONS +ICONS=( + ["screenshot"]="accessories-screenshot" + ["video"]="record-desktop" +) + +declare -A OUTPUT_DIR +OUTPUT_DIR=( + ["screenshot"]="${XDG_PICTURES_DIR:-"~/pictures"}/screenshots" + ["video"]="${XDG_VIDEOS_DIR:="~/videos"}/screenrecords" +) + +declare -A OUTPUT_FILE_EXT +OUTPUT_FILE_EXT=( + ["screenshot"]="png" + ["video"]="mp4" +) + +TO_FILE=0 +RECORD_AUDIO=0 +ACTION="screenshot" +REGION_TYPE="window" + +notify() { + local summary message command + filename="${1:-""}" + summary="New ${ACTION}!" + if [[ $TO_FILE -eq 1 ]]; then + message+="Available in ${filename##*/}" + else + message+="Available in the clipboard" + fi + command=(notify-send "${summary}" --app-name="$APP_NAME") + if [[ -n "$filename" && "$ACTION" == "screenshot" ]]; then + command+=(--icon="${filename}") + else + command+=("--icon=${ICONS[$ACTION]}") + fi + command+=("$message") + "${command[@]}" +} + +process_args() { + while :; do + case ''${1:-""} in + screenshot) + ACTION="$1" + ;; + + video) + # If a video record is in progress Stop it + if pgrep "wl-screenrec"; then + kill -s SIGINT $(pgrep "wl-screenrec") + exit 0 + fi + TO_FILE=1 + ACTION="$1" + ;; + -r | --region) + if [[ "${2:-""}" =~ ^(r|region|s|screen|w|window)$ ]]; then + REGION_TYPE="$2" + else + exit 1 + fi + shift + ;; + -f | --file) + TO_FILE=1 + ;; + -a | --with-audio) + RECORD_AUDIO=1 + ;; + *) + break + ;; + esac + shift + done +} + +get_app_name() { + local appname + case "$REGION_TYPE" in + r | region) + appname="region" + ;; + s | screen) + appname="screen" + ;; + w | window) + appname=$(swaymsg -t get_tree | jq -r '.. | ((.nodes? // empty) + (.floating_nodes? // empty))[] | select(.visible and .pid and .focused) | "\(.app_id)"') + ;; + esac + printf "%s" "${appname:-}" +} + +get_region() { + local region switch + case "$REGION_TYPE" in + r | region) + region=$(slurp) + switch="-g" + ;; + s | screen) + region=$(swaymsg -t get_outputs | jq -r '.[] | select(.focused) | "\(.name)"') + switch="-o" + ;; + w | window) + region=$(swaymsg -t get_tree | jq -r '.. | ((.nodes? // empty) + (.floating_nodes? // empty))[] | select(.visible and .pid and .focused) | .rect | "\(.x),\(.y) \(.width)x\(.height)"') + switch="-g" + ;; + esac + printf "%s%s" "${switch:-}" "${region:-}" +} + +get_output_filename() { + local date + printf -v date '%(%F_%H.%M.%S)T' + printf "%s/%s-%s.%s" "${OUTPUT_DIR[$ACTION]}" "$date" "$(get_app_name)" "${OUTPUT_FILE_EXT[$ACTION]}" +} + +ensure_directories_exist() { + for dir in "${!OUTPUT_DIR[@]}"; do + mkdir -p "${OUTPUT_DIR[$dir]}" + done +} + +main() { + process_args "$@" + ensure_directories_exist + local command + command=("${COMMAND[$ACTION]}" "$(get_region)") + if [[ "$TO_FILE" -eq 1 ]]; then + local filename + filename=$(get_output_filename) + if [[ "$ACTION" = "video" ]]; then + if [[ "$RECORD_AUDIO" -eq 1 ]]; then + command+=(--audio) + fi + command+=(-f) + fi + command+=("$filename") + "${command[@]}" + else + "${command[@]}" - | wl-copy + fi + notify "${filename:-""}" + exit 0 +} + +main "$@" diff --git a/modules/home-manager/desktop/sway/includes/files/waybar-style.css b/modules/home-manager/desktop/sway/includes/files/waybar-style.css new file mode 100644 index 0000000..d1dd1a2 --- /dev/null +++ b/modules/home-manager/desktop/sway/includes/files/waybar-style.css @@ -0,0 +1,134 @@ +@define-color color-base-bg #323232; +@define-color color-base-fg #ddd; + +@define-color color-hover #f268b3; +@define-color color-selected #1cd180; + +@define-color color-ok #1cd180; +@define-color color-warning #f2b768; +@define-color color-critical #f268b3; + +* { + border: none; + border-radius: 0; + min-height:0; +} + +window#waybar { + background: @color-base-bg ; + color: @color-base-fg; + font-family: "Fira Code Nerd Font"; + font-size: 12px; +} + +button, +button:disabled,label:disabled{ + color:inherit; +} + +button:hover{ + background:none; + box-shadow:inherit; + box-shadow:inherit; + text-shadow:inherit; + text-shadow:inherit; + border-top:none; +} +#workspaces { + color:#fff; +} +#workspaces button { + margin:0 3px; + padding:4px 4px; + color:#9c9c9c; + border-bottom: 1px solid transparent; +} + +#workspaces button:hover { + box-shadow:inherit; + text-shadow:inherit; + color: @color-hover; + border-bottom: 1px solid @color-hover; +} + +#workspaces button.focused { + background: @color-selected; + color: @color-base-bg; +} +#workspaces button.visible:not(.focused) { + color: @color-selected; + border-color: @color-selected; +} + +#clock, +#cpu, +#memory, +#backlight, +#network, +#tray, +#mode, +#battery, +#idle_inhibitor { + padding: 2px 4px; + margin: 0; + background-color: transparent; +} + +#mode{ + background:@color-warning; + color: @color-base-bg; + font-weight:200; + font-variant: small-caps; + font-size: 16px; +} +#pulseaudio {} +#pulseaudio.output.muted { + color:@color-critical; +} +#pulseaudio.input.source-muted { + color:@color-critical; +} + +#battery.discharging { + color: @color-base-fg; + border-bottom: none; +} + +#battery.charging, #battery.plugged { + border-bottom: 1px solid @color-ok; + color: @color-selected; +} + +#battery.critical:not(.charging), +#cpu.critical, +#memory.critical, +#temperature.critical{ + border-color: @color-critical; + color: @color-critical; +} + +#battery.warning:not(.charging), +#cpu.warning, +#memory.warning{ + border-color: @color-warning; + color: @color-warning; +} + +#tray { + font-family: "DejaVu sans"; + font-size: 12px; +} +#custom-screenrecord { + color: @color-critical; + border-bottom: 1px solid @color-critical; + animation-name: critical-animation; + animation-duration: 2s; + animation-timing-function: ease-in-out; + animation-direction: alternate; + animation-iteration-count: infinite; +} + +@keyframes critical-animation { + from {color: @color-critical;} + to {color: white;} +} diff --git a/modules/home-manager/desktop/sway/includes/mako.nix b/modules/home-manager/desktop/sway/includes/mako.nix index 3b8d3df..b098010 100644 --- a/modules/home-manager/desktop/sway/includes/mako.nix +++ b/modules/home-manager/desktop/sway/includes/mako.nix @@ -1,5 +1,8 @@ { config, pkgs, lib, ... }: with lib; +let + cfg = config.modules.desktop.sway; +in { config = mkIf config.modules.desktop.sway.enable { systemd.user.services.mako = { @@ -24,12 +27,11 @@ with lib; border-radius = 0; border-size = 2; icons = true; + icon-path = "${cfg.iconTheme}/share/icons/${cfg.iconThemePathname}"; max-icon-size = 64; layer = "overlay"; anchor = "top-right"; - format = '' - %a\n%s\n%b - ''; + format = ''%a\n%s\n%b''; "urgency=high" = { border-color = "#F268b3"; }; diff --git a/modules/home-manager/desktop/sway/includes/sway.nix b/modules/home-manager/desktop/sway/includes/sway.nix index f93d2c6..4f0874c 100644 --- a/modules/home-manager/desktop/sway/includes/sway.nix +++ b/modules/home-manager/desktop/sway/includes/sway.nix @@ -87,8 +87,12 @@ in "${mod}+Shift+space" = "floating toggle"; "${mod}+space" = "focus mode_toggle"; "${mod}+a" = "focus parent"; - "${mod}+Shift+p" = "move scratchpad"; - "${mod}+p" = "scratchpad show"; + "${mod}+Shift+minus" = "move scratchpad"; + "${mod}+minus" = "scratchpad show"; + "${mod}+p" = "exec screencapt --region window"; + "${mod}+Shift+p" = "exec screencapt --region screen"; + "${mod}+Alt+p" = "mode screenshot"; + "${mod}+Alt+r" = "mode screenrecord"; # Media stuff "${mod}+F1" = "exec ${pkgs.brightnessctl}/bin/brightnessctl s 1%-"; "${mod}+F2" = "exec ${pkgs.brightnessctl}/bin/brightnessctl s +1%"; @@ -118,6 +122,27 @@ in "r" = "exec ${pkgs.mako}/bin/makoctl restore"; "Escape" = "mode default"; }; + "screenshot" = { + "s" = "exec screencapt --region screen; mode default"; + "Shift+s" = "exec screencapt --region screen -f; mode default"; + "r" = "exec screencapt --region region; mode default"; + "Shift+r" = "exec screencapt --region region -f; mode default"; + "w" = "exec screencapt --region window; mode default"; + "Shift+w" = "exec screencapt --region window -f; mode default"; + "Return" = "mode default"; + "Escape" = "mode default"; + }; + "screenrecord" = { + "s" = "exec screencapt video --region screen; mode default"; + "Shift+s" = "exec screencapt --region video screen -a; mde default"; + "r" = "exec screencapt video --region region; mode default"; + "Shift+r" = "exec screencapt video --region region -a; mode default"; + "w" = "exec screencapt video --region window -f ; mode default"; + "Shift+w" = "exec screencapt --region video window -a; mode default"; + "Return" = "mode default"; + "Escape" = "mode default"; + }; + }; colors = { focused = { @@ -214,5 +239,9 @@ in title_align right ''; }; + home.file.".local/bin/screencapt" = { + executable = true; + source = ./files/screencapt.sh; + }; }; } diff --git a/modules/home-manager/desktop/sway/includes/waybar.nix b/modules/home-manager/desktop/sway/includes/waybar.nix index d46baf1..3f74082 100644 --- a/modules/home-manager/desktop/sway/includes/waybar.nix +++ b/modules/home-manager/desktop/sway/includes/waybar.nix @@ -1,4 +1,4 @@ -{lib, config, ...}: +{lib, config, pkgs, ...}: with lib; let cfg = config.modules.desktop.sway; @@ -16,7 +16,9 @@ in layer = "top"; spacing = 6; disable-toolptips = true; - modules-center = []; + modules-center = [ + "custom/screenrecord" + ]; modules-left = [ "sway/workspaces" "sway/mode" @@ -48,10 +50,12 @@ in ] ) ++ [ - "pulseaudio" + "pulseaudio#input" + "pulseaudio#output" "custom/sep" "clock" "custom/sep" + "privacy" "tray" ]; "clock" = { @@ -72,6 +76,14 @@ in "format" = "|"; "tooltip" = false; }; + "custom/screenrecord" = { + "format" = "  [rec.] "; + "interval" = 1; + "exec" = "echo '{\"class\": \"recording\"}'"; + "exec-if" = "${pkgs.procps}/bin/pgrep wl-screenrec"; + "on-click" = "exec ${pkgs.coreutils}/bin/kill -s SIGINT $(${pkgs.procps}/bin/pgrep wl-screenrec)"; + "tooltype" = false; + }; "idle_inhibitor" = { "format" = "{icon}"; "format-icons" = { @@ -80,7 +92,7 @@ in }; }; "memory" = { - "format" = "{used:0.1f}G/{total:0.1f}G "; + "format" = "{used:0.0f}/{total:0.0f}G "; "interval" = 30; "states" = { "critical" = 90; @@ -88,27 +100,51 @@ in }; }; "network" = { - "format-alt" = "{ifname}: {ipaddr}/{cidr}"; + "format-alt" = "{ifname}: {essid} {ipaddr}/{cidr} 󰈀 "; "format-disconnected" = "Disconnected ⚠ "; - "format-ethernet" = "{ifname}: {ipaddr}/{cidr} 󰈀 "; + "format-ethernet" = "{ifname} 󰈀 "; "format-linked" = "{ifname} (No IP) 󰈀 "; - "format-wifi" = "{essid} ({signalStrength}%)  "; + "format-wifi" = "{signalStrength}%  "; "tooltip" = false; }; - "pulseaudio" = { - "format" = "{format_source} {volume}% {icon} "; + "privacy"= { + "icon-spacing" = 6; + "icon-size" = 11; + "transition-duration" = 250; + "modules"= [ + { + "type" = "screenshare"; + "tooltip" = false; + } + { + "type" = "audio-out"; + "tooltip" = false; + } + { + "type" = "audio-in"; + "tooltip" = false; + } + ]; + "ignore-monitor" = true; + }; + "pulseaudio#output" = { + "format" = "{volume}% {icon} "; "format-bluetooth" = "{volume}% {icon}"; "format-icons" = { "car" = ""; - "default" = ""; + "default" = "󰕾"; "hands-free" = "󰋎"; "headphone" = "󰋋"; "headset" = "󰋎"; "phone" = ""; "portable" = ""; }; - "format-muted" = "{format_source} 󰝟 "; - "format-source" = "{volume}%  "; + "format-muted" = "󰖁 "; + "tooltip" = false; + }; + "pulseaudio#input" = { + "format" = "{format_source} "; + "format-source" = "{volume}% "; "format-source-muted" = " "; "tooltip" = false; }; @@ -120,7 +156,7 @@ in }; "temperature" = { "critical-threshold" = 80; - "format" = "{temperatureC}°C  "; + "format" = " {temperatureC}°C  "; "thermal-zone" = mkIf ( cfg.waybar.cpuThermal.thermalZone != "" ) "${cfg.waybar.cpuThermal.thermalZone}"; "hwmon-path-abs" = mkIf ( cfg.waybar.cpuThermal.hwmonPathAbs != "" ) @@ -170,121 +206,7 @@ in }; }; }; - style = '' - @define-color color-base-bg #323232; - @define-color color-base-fg #ddd; - - @define-color color-hover #f268b3; - @define-color color-selected #1cd180; - - @define-color color-ok #1cd180; - @define-color color-warning #f2b768; - @define-color color-critical #f268b3; - - * { - border: none; - border-radius: 0; - min-height:0; - } - - window#waybar { - background: @color-base-bg ; - color: @color-base-fg; - font-family: "Fira Code Nerd Font"; - font-size: 12px; - } - - button, - button:disabled,label:disabled{ - color:inherit; - } - - button:hover{ - background:none; - box-shadow:inherit; - box-shadow:inherit; - text-shadow:inherit; - text-shadow:inherit; - border-top:none; - } - #workspaces { - color:#fff; - } - #workspaces button { - margin:0 3px; - padding:4px 4px; - color:#9c9c9c; - border-bottom: 1px solid transparent; - } - - #workspaces button:hover { - box-shadow:inherit; - text-shadow:inherit; - color: @color-hover; - border-bottom: 1px solid @color-hover; - } - - #workspaces button.focused { - background: @color-selected; - color: @color-base-bg; - } - #workspaces button.visible:not(.focused) { - color: @color-selected; - border-color: @color-selected; - } - - #clock, - #cpu, - #memory, - #backlight, - #network, - #tray, - #mode, - #battery, - #idle_inhibitor { - padding: 2px 4px; - margin: 0; - background-color: transparent; - } - - #mode{ - background:@color-warning; - font-weight:bold; - } - #pulseaudio {} - #pulseaudio.muted { - color:@color-critical; - } - - #battery.discharging { - color: @color-base-fg; - border-bottom: none; - } - - #battery.charging, #battery.plugged { - border-bottom: 1px solid @color-ok; - color: @color-selected; - } - - #battery.critical:not(.charging), - #cpu.critical, - #memory.critical{ - border-color: @color-critical; - color: @color-critical; - } - - #battery.warning:not(.charging), - #cpu.warning, - #memory.warning{ - border-color: @color-warning; - color: @color-warning; - } - - #tray { - font-family: "DejaVu sans"; - font-size: 12px; - } - ''; + style = builtins.readFile ./files/waybar-style.css; }; }; }