move tmux script into package

This commit is contained in:
Adithya 2023-04-06 03:08:26 +05:30
parent 68bc7f8c78
commit 98311d4807
Signed by: adtya
GPG key ID: 48FC9915FFD326D0
3 changed files with 18 additions and 28 deletions

View file

@ -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'';
};
};
}

View file

@ -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 ]}
'';
}

View file

@ -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