-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathadd-to-steam-gui.sh
47 lines (43 loc) · 1.76 KB
/
add-to-steam-gui.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/bin/sh
INSTALLED_APPS_DIR=/tmp/.installed_apps/
add_to_steam() {
encodedUrl="steam://addnonsteamgame/$(python3 -c "import urllib.parse;print(urllib.parse.quote(\"$1\", safe=''))")"
touch /tmp/addnonsteamgamefile
# zenity --info --text="Add to steam: ${encodedUrl}" #DEBUG
xdg-open $encodedUrl
}
### prepare quick access applications directory
rm $INSTALLED_APPS_DIR/*
rmdir $INSTALLED_APPS_DIR
mkdir -p $INSTALLED_APPS_DIR
for i in /var/lib/flatpak/app/*/current/active/export/share/applications/* /usr/share/applications/*; do
name=`cat $i | grep -m 1 "^Name="`
name=${name:5} ### cut out "Name="
filename=$(basename "$i")
### collect only .desktop files
if [[ $filename == *.desktop ]]; then
if [[ -e $INSTALLED_APPS_DIR/"${name}" ]]; then
ln -s $i $INSTALLED_APPS_DIR/"${name}_"${filename} ### unique names for duplicities
else
ln -s $i $INSTALLED_APPS_DIR/"${name}"
fi
fi
done
### let user select application to add to Steam
add_to_steam_file=`zenity --file-selection --filename=$INSTALLED_APPS_DIR --title="Add to Steam"`
case $? in
0)
# zenity --info --text="Selected file: ${add_to_steam_file}" #DEBUG
if [[ "$add_to_steam_file" == $INSTALLED_APPS_DIR* ]]
then
# resolve symlink of quick access desktop files
add_to_steam_file=`readlink "$add_to_steam_file"`
# zenity --info --text="Resolved link: ${add_to_steam_file}" #DEBUG
fi
add_to_steam "$add_to_steam_file"
;;
1)
zenity --info --text="No file selected.";;
*)
zenity --error --text="An unexpected error has occurred.";;
esac