Skip to content

Instantly share code, notes, and snippets.

@rany2
Created July 11, 2021 15:07
Show Gist options
  • Select an option

  • Save rany2/426b7cf63b87ec832bc91c3e176b05c0 to your computer and use it in GitHub Desktop.

Select an option

Save rany2/426b7cf63b87ec832bc91c3e176b05c0 to your computer and use it in GitHub Desktop.
Get command from every flatpak app and generate wrapper script for it
#!/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