playshellsound is now a standalone script

This commit is contained in:
2024-11-17 11:20:31 -05:00
parent 93acf864ea
commit 21f11673b6
5 changed files with 51 additions and 28 deletions

View File

@@ -36,6 +36,7 @@ let
myScripts.s_check
myScripts.switchmon
myScripts.git-compose
myScripts.playshellsound
];
in {
options = {

View File

@@ -1,5 +1,9 @@
{ lib, config, self, ... }:
{ lib, config, self, pkgs, ... }:
let
shellsound = "${pkgs.myScripts.playshellsound}/bin/playshellsound";
sndpath = "${self}/assets/sound";
in
{
options = {
movOpts.envConfig.zshConfig.extraConfig.enable = lib.mkEnableOption "enables my extra shell configurations";
@@ -7,17 +11,6 @@
config = lib.mkIf config.movOpts.envConfig.zshConfig.extraConfig.enable {
programs.zsh = {
initExtra = ''
playshellsound() {
if [ $# -ne 1 ]; then
echo "Usage: playshellsound <path/to/sound>"
return 1
fi
if ! scheck; then
return 0
else
runbg aplay "$1"
fi
}
build-drv() { # Put the derivation path in $RESULT instead of making a 'result' symlink
RESULT=$(nix-build "$@" --no-link)
if [ -z "$RESULT" ]; then
@@ -26,6 +19,11 @@
export RESULT
echo "\$RESULT = $RESULT"
}
nvim() {
${shellsound} ${sndpath}/nvim.wav
command nvim "$@"
}
alias vi="nvim"
ssh() { # reverts ssh theme upon returning
command ssh "$@"
kitty_ssh_theme
@@ -39,58 +37,58 @@
}
grimblast() {
if grimblast "$@"; then
playshellsound ${self}/assets/sound/screenshot.wav
${shellsound} ${sndpath}/screenshot.wav
fi
}
gitcheckout_sfx() {
if git checkout "$@"; then
playshellsound ${self}/assets/sound/gitcheckout.wav
${shellsound} ${sndpath}/gitcheckout.wav
return 0
else
playshellsound ${self}/assets/sound/error.wav
${shellsound} ${sndpath}/error.wav
return 1
fi
}
gitrebase_sfx() {
if git rebase "$@"; then
playshellsound ${self}/assets/sound/gitrebase.wav
${shellsound} ${sndpath}/gitrebase.wav
return 0
else
playshellsound ${self}/assets/sound/error.wav
${shellsound} ${sndpath}/error.wav
return 1
fi
}
gitcommit_sfx() {
if git commit "$@"; then
playshellsound ${self}/assets/sound/gitcommit.wav
${shellsound} ${sndpath}/gitcommit.wav
return 0
else
playshellsound ${self}/assets/sound/error.wav
${shellsound} ${sndpath}/error.wav
return 1
fi
}
gitpush_sfx() {
if git push "$@"; then
playshellsound ${self}/assets/sound/gitpush.wav
${shellsound} ${sndpath}/gitpush.wav
return 0
else
playshellsound ${self}/assets/sound/error.wav
${shellsound} ${sndpath}/error.wav
return 1
fi
}
gitpull_sfx() {
if git pull "$@"; then
playshellsound ${self}/assets/sound/gitpull.wav
${shellsound} ${sndpath}/gitpull.wav
return 0
else
playshellsound ${self}/assets/sound/error.wav
${shellsound} ${sndpath}/error.wav
return 1
fi
}
unalias ls
ls() {
eza -1 --group-directories-first --icons "$@"
playshellsound ${self}/assets/sound/ls.wav
${shellsound} ${sndpath}/ls.wav
return 0
}
@@ -113,7 +111,7 @@
eza -1 --group-directories-first --icons "$@"
SOUNDS_ENABLED=$prev_sounds_enabled
builtin cd "$@"
playshellsound /nix/store/7a9w7np3qrvmzxjbs7xj05qq2yccgfsj-source/assets/sound/cd.wav
${shellsound} /nix/store/7a9w7np3qrvmzxjbs7xj05qq2yccgfsj-source/assets/sound/cd.wav
return 0
}
if [ ! -e $HOME/.zsh_history ]; then
@@ -157,7 +155,7 @@
{
eval "$(starship init zsh)"
}
playshellsound ${self}/assets/sound/sh-source.wav
${shellsound} ${sndpath}/sh-source.wav
[ ! -f $FLAKEPATH/flake.nix ] && echo "WARNING: flake.nix not found at \$FLAKEPATH. Shell aliases for editing config files won't work correctly!" && echo "Edit the FLAKEPATH session variable in zshell.nix to point to the path where you saved the system configuration flake."
'';
};

View File

@@ -23,6 +23,7 @@
chpaper = super.callPackage ./scripts/wm-controls/chpaper.nix {};
chscheme = super.callPackage ./scripts/wm-controls/chscheme.nix {};
keyring = super.callPackage ./scripts/wm-controls/keyring.nix {};
playshellsound = super.callPackage ./scripts/wm-controls/playshellsound.nix {};
mkscreenshots = super.callPackage ./scripts/wm-controls/mkscreenshots.nix {};
moveonscreen = super.callPackage ./scripts/wm-controls/moveonscreen.nix {};
s_check = super.callPackage ./scripts/wm-controls/s_check.nix {};

View File

@@ -1,6 +1,9 @@
{ host, self, pkgs, }:
pkgs.writeShellApplication {
name = "rebuild";
runtimeInputs = [
pkgs.myScripts.playshellsound
];
text = ''
checkbools() { [ "$all" = false ] && [ "$system" = false ] && [ "$home" = false ]; }
checkflags() {
@@ -24,8 +27,8 @@ pkgs.writeShellApplication {
all=false
dry=false
hooray() { scheck && runbg aplay "${self}/assets/sound/update.wav"; }
damn() { scheck && runbg aplay "${self}/assets/sound/error.wav"; }
hooray() { playshellsound "${self}/assets/sound/update.wav"; }
damn() { playshellsound "${self}/assets/sound/error.wav"; }
usage="\033[1;4;38;2;243;139;168mUsage\033[0m: rebuild -h for home config, rebuild -s for sys config, rebuild -a for both. Including 'n' with the flag does a dry run, i.e. rebuild -nh"

View File

@@ -0,0 +1,20 @@
{ pkgs }:
pkgs.writeShellApplication {
name = "playshellsound";
runtimeInputs = with pkgs; [
alsa-utils
pkgs.myScripts.runbg
];
text = ''
if [ $# -ne 1 ]; then
echo "Usage: playshellsound <path/to/sound>"
exit 1
fi
if scheck; then
runbg aplay "$1"
else
exit 1
fi
'';
}