Created
July 11, 2021 15:07
-
-
Save rany2/426b7cf63b87ec832bc91c3e176b05c0 to your computer and use it in GitHub Desktop.
Get command from every flatpak app and generate wrapper script for it
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env bash | |
| set -ef | |
| if [ -z "$1" ] | |
| then | |
| outdir="output" | |
| else | |
| outdir="$1" | |
| fi | |
| mkdir -p "$outdir" | |
| set -u | |
| while read -r appid | |
| do | |
| command="$(flatpak info -m "$appid" | awk -F= '/^command=/ { print $2; exit 0; }')" | |
| filename="$outdir/$command" | |
| newfilename="$filename" | |
| suffix=0 | |
| while [ -f "${newfilename}" ] | |
| do | |
| suffix=$((suffix+1)) | |
| newfilename="${filename}_${suffix}" | |
| done | |
| filename="$newfilename" | |
| unset newfilename suffix | |
| cat > "$filename" <<-EOF | |
| #!/bin/bash | |
| exec flatpak run --command="$command" "$appid" "\$@" | |
| EOF | |
| chmod +x "$filename" | |
| done < <(flatpak list --app --columns=application) | |
| exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment