diff --git a/modules/home/scripts/default.nix b/modules/home/scripts/default.nix index a6dd18b..b232be5 100644 --- a/modules/home/scripts/default.nix +++ b/modules/home/scripts/default.nix @@ -34,14 +34,46 @@ echo "Git wasn't initialized here." fi ''; + dsize = pkgs.writeShellScriptBin "dsize" '' + if [ "$#" -eq 1 ]; then + du -hs $1 + else + echo "[ERROR] => Wrong number of parameters" + fi + ''; + runbg = pkgs.writeShellScriptBin "runbg" '' + [ $# -eq 0 ] && { # $# is number of args + echo "$(basename $0): missing command" >&2 + exit 1 + } + prog="$(which "$1")" # see below + [ -z "$prog" ] && { + echo "$(basename $0): unknown command: $1" >&2 + exit 1 + } + shift # remove $1, now $prog, from args + tty -s && exec /dev/null # if stdout is a terminal, redirect to null + tty -s <&2 && exec 2>&1 # stderr to stdout (which might not be null) + "$prog" "$@" & # $@ is all args + ''; + music = pkgs.writeShellScriptBin "music" '' + if [[ $# == 0 ]]; then + runbg audacious -t + elif [[ $1 == -s ]]; then + pkill audacious + else + echo "[ERROR] => Wrong argument..." + fi + ''; in { - home.file.".local/bin/dsize".source = ./dsize; - home.file.".local/bin/runbg".source = ./runbg; - home.file.".local/bin/music".source = ./music; home.packages = with pkgs; [ wall-change wallpaper-picker push commit + dsize + runbg + music ]; }