From 98311d4807f860f51ce15419c541dd4c406dbe8c Mon Sep 17 00:00:00 2001 From: Adithya Nair Date: Thu, 6 Apr 2023 03:08:26 +0530 Subject: [PATCH] move tmux script into package --- home/scripts.nix | 26 -------------------------- packages/scripts/default.nix | 8 ++++++-- packages/scripts/tmux-sessions.sh | 12 ++++++++++++ 3 files changed, 18 insertions(+), 28 deletions(-) create mode 100644 packages/scripts/tmux-sessions.sh diff --git a/home/scripts.nix b/home/scripts.nix index 54a2546..df9095f 100644 --- a/home/scripts.nix +++ b/home/scripts.nix @@ -1,8 +1,4 @@ { osConfig, pkgs, ... }: -let - notify-send = "${pkgs.libnotify}/bin/notify-send"; - dmenu = "${pkgs.rofi-wayland}/bin/rofi -dmenu"; -in { xdg.configFile = { "scripts/chpaper.sh" = { @@ -27,27 +23,5 @@ in ''; executable = true; }; - - "scripts/tmux_sessions.sh" = - let - kitty = "${pkgs.kitty}/bin/kitty"; - tmux = "${pkgs.tmux}/bin/tmux"; - in - { - executable = true; - text = '' - #!/bin/sh - - set -eu - - SESSION="$(${tmux} list-sessions -F "(#{session_attached}) #S [#{pane_current_command} in #{pane_current_path}] #{pane_title}" | sort | ${dmenu} -p "Running TMUX Sessions" | awk '{print $2}')" - case "$SESSION" in - "") - ;; - *) - ${kitty} ${tmux} -u attach-session -dEt "$SESSION" - ;; - esac''; - }; }; } diff --git a/packages/scripts/default.nix b/packages/scripts/default.nix index fd48559..145393d 100644 --- a/packages/scripts/default.nix +++ b/packages/scripts/default.nix @@ -1,4 +1,4 @@ -{ lib, stdenvNoCC, makeWrapper, libnotify, rofi-wayland }: +{ lib, stdenvNoCC, makeWrapper, libnotify, rofi-wayland, tmux, kitty }: stdenvNoCC.mkDerivation { pname = "scripts"; @@ -6,12 +6,16 @@ stdenvNoCC.mkDerivation { src = ./.; nativeBuildInputs = [ makeWrapper ]; - buildInputs = [ libnotify rofi-wayland power-profiles-daemon ]; + buildInputs = [ libnotify rofi-wayland tmux kitty ]; installPhase = '' mkdir -p $out/bin cp power-menu.sh $out/bin/power-menu chmod +x $out/bin/power-menu wrapProgram $out/bin/power-menu --prefix PATH : ${lib.makeBinPath [ libnotify rofi-wayland ]} + + cp tmux-sessions.sh $out/bin/tmux-sessions + chmod +x $out/bin/tmux-sessions + wrapProgram $out/bin/tmux-sessions --prefix PATH : ${lib.makeBinPath [ tmux kitty rofi-wayland ]} ''; } diff --git a/packages/scripts/tmux-sessions.sh b/packages/scripts/tmux-sessions.sh new file mode 100644 index 0000000..5f6ade5 --- /dev/null +++ b/packages/scripts/tmux-sessions.sh @@ -0,0 +1,12 @@ +#!/bin/sh + +set -eu + +SESSION="$(tmux list-sessions -F "(#{session_attached}) #S [#{pane_current_command} in #{pane_current_path}] #{pane_title}" | sort | rofi -dmenu -p "Running TMUX Sessions" | awk '{print $2}')" +case "$SESSION" in + "") + ;; + *) + kitty tmux attach-session -dEt "$SESSION" + ;; +esac