diff options
| author | Fuwn <[email protected]> | 2025-01-01 01:37:16 -0800 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2025-01-01 01:37:16 -0800 |
| commit | 5b3f0dea1fb8126576ea7a3f3492d52a0b27c619 (patch) | |
| tree | fa8c22bb30253d38ae51da8a97dfbb176e5fd13d /scripts | |
| parent | nara: add all mas apps (diff) | |
| download | nixos-config-5b3f0dea1fb8126576ea7a3f3492d52a0b27c619.tar.xz nixos-config-5b3f0dea1fb8126576ea7a3f3492d52a0b27c619.zip | |
nara: add mas apps generator script
Diffstat (limited to 'scripts')
| -rwxr-xr-x | scripts/generate_clean_mas_apps.sh | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/scripts/generate_clean_mas_apps.sh b/scripts/generate_clean_mas_apps.sh new file mode 100755 index 0000000..b1ea2ab --- /dev/null +++ b/scripts/generate_clean_mas_apps.sh @@ -0,0 +1,41 @@ +#!/usr/bin/env bash + +if ! command -v mas &>/dev/null; then + echo "error: mas not found" + exit 1 +fi + +echo "fetching installed apps from app store ..." + +apps=$(mas list) + +if [[ -z "${apps}" ]]; then + echo "no apps installed from app store" + exit 0 +fi + +output="masApps = {\n" + +while IFS= read -r line; do + app_id=$(echo "${line}" | awk '{print $1}') + app_name=$(echo "${line}" | + cut -d' ' -f2- | + sed -E 's/\([^)]+\)$//' | + sed 's/[[:space:]]+$//' | + sed 's/^[[:space:]]*//;s/[[:space:]]*$//') + + if [[ "${app_name}" =~ [[:space:]] ]]; then + output+=" \"${app_name}\" = ${app_id};\n" + else + output+=" ${app_name} = ${app_id};\n" + fi +done <<<"${apps}" + +output+="};" + +# echo -e "${output}" + +output_file="mas_apps.nix" + +echo -e "${output}" >"${output_file}" +echo "write to ${output_file}" |