From 34d86d83e848020764f419458ca888532893eec3 Mon Sep 17 00:00:00 2001 From: bee Date: Fri, 8 May 2026 02:03:19 +0530 Subject: tmux wrapped terminal script --- common/modules/window_managers/default.nix | 1 + common/modules/window_managers/dwm/default.nix | 40 ++++------------------ .../modules/window_managers/hyprland/default.nix | 18 ++-------- common/modules/window_managers/mango/default.nix | 16 ++------- common/modules/window_managers/scripts.nix | 23 +++++++++++++ 5 files changed, 34 insertions(+), 64 deletions(-) create mode 100644 common/modules/window_managers/scripts.nix (limited to 'common/modules') diff --git a/common/modules/window_managers/default.nix b/common/modules/window_managers/default.nix index 6591583..bc93e35 100644 --- a/common/modules/window_managers/default.nix +++ b/common/modules/window_managers/default.nix @@ -63,6 +63,7 @@ in cliphist brightnessctl maim + wtype ]; } else diff --git a/common/modules/window_managers/dwm/default.nix b/common/modules/window_managers/dwm/default.nix index d1f7850..49537a2 100644 --- a/common/modules/window_managers/dwm/default.nix +++ b/common/modules/window_managers/dwm/default.nix @@ -12,37 +12,12 @@ }: let cfg = config.${moduleNameSpace}.windowManagers; - snipx11 = pkgs.writeShellScript "snipx11" '' - case $1 in - full) - ${pkgs.maim}/bin/maim | xclip -selection clipboard -t image/png - ;; - selection) - ${pkgs.maim}/bin/maim -s | xclip -selection clipboard -t image/png - ;; - window) - ${pkgs.maim}/bin/maim -i $(xdotool getactivewindow) | xclip -selection clipboard -t image/png - ;; - esac - ''; st-patched = (pkgs.st.override { extraLibs = [ pkgs.libXcursor ]; }).overrideAttrs (oldAttrs: rec { patches = map pkgs.fetchpatch [ - { - url = "https://st.suckless.org/patches/scrollback/st-scrollback-0.9.2.diff"; - sha256 = "sha256-ZypvRONAHS//wnZjivmqpWIqZlKTqAQ0Q8DhQpZVaqU="; - } - { - url = "https://st.suckless.org/patches/scrollback/st-scrollback-mouse-0.9.2.diff"; - sha256 = "sha256-CuNJ5FdKmAtEjwbgKeBKPJTdEfJvIdmeSAphbz0u3Uk="; - } - { - url = "https://st.suckless.org/patches/scrollback/st-scrollback-mouse-altscreen-20220127-2c5edf2.diff"; - sha256 = "sha256-8oVLgbsYCfMhNEOGadb5DFajdDKPxwgf3P/4vOXfUFo="; - } { url = "https://st.suckless.org/patches/xresources/st-xresources-20230320-45a15676.diff"; sha256 = "sha256-WcL9IeyanXFiOFDGGRU0QNT8DU7wSo2o+3n+TaqASUY="; @@ -71,16 +46,13 @@ let url = "https://st.suckless.org/patches/boxdraw/st-boxdraw_v2-0.8.5.diff"; sha256 = "sha256-WN/R6dPuw1eviHOvVVBw2VBSMDtfi1LCkXyX36EJKi4="; } - # { - # url = "https://st.suckless.org/patches/themed_cursor/st-themed_cursor-0.8.1.diff"; - # sha256 = "sha256-Q/6VN9oCrdJiZPPjKMpw3UB09tIs4eJ1Hi5c8k7O7uo="; - # } + { + url = "https://st.suckless.org/patches/bold-is-not-bright/st-bold-is-not-bright-20190127-3be4cf1.diff"; + sha256 = "sha256-IhrTgZ8K3tcf5HqSlHm3GTacVJLOhO7QPho6SCGXTHw="; + } ]; postPatch = oldAttrs.postPatch or "" + '' - sed -i 's/Button4, *kscrollup, *{.i = 1}/Button4, kscrollup, {.i = 10}/g' config.def.h - sed -i 's/Button5, *kscrolldown, *{.i = 1}/Button5, kscrolldown, {.i = 10}/g' config.def.h - sed -i 's/const int boxdraw = 0;/const int boxdraw = 1;/g' config.def.h sed -i 's/const int boxdraw_bold = 0;/const int boxdraw_bold = 1;/g' config.def.h @@ -194,10 +166,10 @@ in "Xft.hintstyle" = "hintfull"; "Xft.rgba" = "rgb"; "st.font" = - "${config.beeMods.terminal.font.family}:size=${toString config.beeMods.terminal.font.size}:antialias=true:autohint=true"; + "JetBrainsMono Nerd Font:size=${toString config.beeMods.terminal.font.size}:antialias=true:autohint=true"; "dmenu.font" = "${config.beeMods.terminal.font.family}:size=${toString config.beeMods.terminal.font.size}"; - "st.borderpx" = 2; + # "st.borderpx" = 2; }; } ); diff --git a/common/modules/window_managers/hyprland/default.nix b/common/modules/window_managers/hyprland/default.nix index aaf202f..fea9db6 100644 --- a/common/modules/window_managers/hyprland/default.nix +++ b/common/modules/window_managers/hyprland/default.nix @@ -12,21 +12,7 @@ }: let cfg = config.${moduleNameSpace}.windowManagers; - smart-alacritty = pkgs.writeShellScript "smart-alacritty" '' - alacritty msg create-window || exec alacritty - ''; - - smart-ghostty = pkgs.writeShellScript "smart-ghostty" '' - ghostty +new-window || exec ghostty - ''; - - terminal = - if config.beeMods.terminal.default == "alacritty" then - smart-alacritty - else if config.beeMods.terminal.default == "ghostty" then - smart-ghostty - else - config.beeMods.terminal.default; + scripts = import ../scripts.nix { inherit pkgs config; }; in { config = lib.mkIf cfg.hyprland.enable ( @@ -222,7 +208,7 @@ in bind = [ "$mainMod, r, exec, hyprctl reload" - "$mainMod, Return, exec, ${terminal}" + "$mainMod, Return, exec, ${scripts.terminal}" "$mainMod, a, exec,noctalia-shell ipc call launcher toggle" "$mainMod, y, exec,noctalia-shell ipc call wallpaper toggle" "$mainMod, v, exec,noctalia-shell ipc call launcher clipboard" diff --git a/common/modules/window_managers/mango/default.nix b/common/modules/window_managers/mango/default.nix index 41c6f5c..73db1ab 100644 --- a/common/modules/window_managers/mango/default.nix +++ b/common/modules/window_managers/mango/default.nix @@ -12,6 +12,7 @@ }: let cfg = config.${moduleNameSpace}.windowManagers; + scripts = import ../scripts.nix { inherit pkgs config; }; snip = pkgs.writeShellScript "snip" '' case $1 in full) @@ -32,19 +33,6 @@ let ;; esac ''; - smart-alacritty = pkgs.writeShellScript "smart-alacritty" '' - alacritty msg create-window || exec alacritty - ''; - smart-ghostty = pkgs.writeShellScript "smart-ghostty" '' - ghostty +new-window || exec ghostty - ''; - terminal = - if config.beeMods.terminal.default == "alacritty" then - smart-alacritty - else if config.beeMods.terminal.default == "ghostty" then - smart-ghostty - else - config.beeMods.terminal.default; in { imports = @@ -224,7 +212,7 @@ in # reload config bind=SUPER,r,reload_config - bind=SUPER,Return,spawn,${terminal} + bind=SUPER,Return,spawn,${scripts.terminal} bind=SUPER,v,spawn,noctalia-shell ipc call launcher clipboard bind=SUPER,a,spawn,noctalia-shell ipc call launcher toggle diff --git a/common/modules/window_managers/scripts.nix b/common/modules/window_managers/scripts.nix new file mode 100644 index 0000000..1d854ae --- /dev/null +++ b/common/modules/window_managers/scripts.nix @@ -0,0 +1,23 @@ +{ pkgs, config }: + +{ + terminal = pkgs.writeShellScript "terminal" '' + TERM="${config.beeMods.terminal.default}" + SESSION="_main" + + if pgrep -x "$TERM" >/dev/null; then + if tmux ls &>/dev/null; then + tmux neww + exit 0 + else + exec $TERM -e tmux new -s $SESSION + fi + else + if tmux ls &>/dev/null; then + exec $TERM -e tmux attach + else + exec $TERM -e tmux new -s $SESSION + fi + fi + ''; +} -- cgit v1.3.1