tweaks on several shell utilities

This commit is contained in:
2024-11-19 18:59:30 -05:00
parent 590e715613
commit 836f24d416
6 changed files with 12 additions and 9 deletions

View File

@@ -37,7 +37,7 @@ in
fi
}
grimblast() {
if grimblast "$@"; then
if command grimblast "$@"; then
${shellsound} ${sndpath}/screenshot.wav
fi
}

View File

@@ -27,7 +27,7 @@ in
# Scripts written using pkgs.writeShellApplication
icanhazip = super.callPackage ./scripts/commands/icanhazip.nix {};
invoke = super.callPackage ./scripts/commands/invoke.nix { self = root; };
git-compose = super.callPackage ./scripts/commands/git-compose.nix {};
git-compose = super.callPackage ./scripts/commands/git-compose.nix { self = root; };
runbg = super.callPackage ./scripts/commands/runbg.nix {};
splash = super.callPackage ./scripts/commands/splash.nix {};
toolbelt = super.callPackage ./scripts/commands/toolbelt.nix {};

View File

@@ -1,10 +1,13 @@
{ pkgs }:
{ pkgs, self }:
pkgs.writeShellApplication {
name = "git-compose";
runtimeInputs = with pkgs; [
git
alsa-utils
gawk
myScripts.color-commit
myScripts.s_check
myScripts.playshellsound
];
text = ''
set -e
@@ -83,6 +86,7 @@ pkgs.writeShellApplication {
git add "''${lines[@]}"
git commit -m "$msg" | color-commit
fi
playshellsound ${self}/assets/sound/gitcommit.wav
)
'';
}

View File

@@ -10,8 +10,9 @@ pkgs.writeShellApplication {
STACK_FILE="/tmp/mntstack.txt"
validate_entry() {
local entry_dev entry_mntpoint test_mntpoint
local entry_dev entry_mntpoint
IFS=' ' read -r entry_dev entry_mntpoint <<< "$1"
echo "$entry_dev" > /dev/null # Don't ask
[ -n "$(findmnt -no SOURCE,TARGET "$entry_mntpoint" | cut -d' ' -f1-)" ]
}
@@ -67,9 +68,9 @@ pkgs.writeShellApplication {
mapfile -t stack < "$STACK_FILE"
# Get the last entry
last_path="${stack[-1]}"
last_path="''${stack[-1]}"
if ! validate_entry "$last_path"; then
echo "Warning: Invalid stack entry '${stack[-1]}'"
echo -e "Warning: Invalid stack entry \"''${stack[-1]}\""
sed -i '$d' "$STACK_FILE"
return 0
fi

View File

@@ -28,7 +28,7 @@ pkgs.writeShellApplication {
# Get the size of the trash folder before deleting
if [ "$(ls -A ~/.local/share/Trash/files/ 2>/dev/null)" ]; then
rm_freed=$(du -sm ~/.local/share/Trash/files | awk '{print $1}')
/run/current-system/sw/bin/rm -rfv ~/.local/share/Trash/files/* # Verbose output
/run/current-system/sw/bin/rm -rf ~/.local/share/Trash/files/*
mkdir -p ~/.local/share/Trash/files
else
rm_freed="0"

View File

@@ -2,8 +2,6 @@
pkgs.writeShellApplication {
name = "scheck";
text = ''
#!/run/current-system/sw/bin/bash
[ "$SOUNDS_ENABLED" = "true" ]
'';
}