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 fi
} }
grimblast() { grimblast() {
if grimblast "$@"; then if command grimblast "$@"; then
${shellsound} ${sndpath}/screenshot.wav ${shellsound} ${sndpath}/screenshot.wav
fi fi
} }

View File

@@ -27,7 +27,7 @@ in
# Scripts written using pkgs.writeShellApplication # Scripts written using pkgs.writeShellApplication
icanhazip = super.callPackage ./scripts/commands/icanhazip.nix {}; icanhazip = super.callPackage ./scripts/commands/icanhazip.nix {};
invoke = super.callPackage ./scripts/commands/invoke.nix { self = root; }; 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 {}; runbg = super.callPackage ./scripts/commands/runbg.nix {};
splash = super.callPackage ./scripts/commands/splash.nix {}; splash = super.callPackage ./scripts/commands/splash.nix {};
toolbelt = super.callPackage ./scripts/commands/toolbelt.nix {}; toolbelt = super.callPackage ./scripts/commands/toolbelt.nix {};

View File

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

View File

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

View File

@@ -28,7 +28,7 @@ pkgs.writeShellApplication {
# Get the size of the trash folder before deleting # Get the size of the trash folder before deleting
if [ "$(ls -A ~/.local/share/Trash/files/ 2>/dev/null)" ]; then if [ "$(ls -A ~/.local/share/Trash/files/ 2>/dev/null)" ]; then
rm_freed=$(du -sm ~/.local/share/Trash/files | awk '{print $1}') 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 mkdir -p ~/.local/share/Trash/files
else else
rm_freed="0" rm_freed="0"

View File

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