-
Notifications
You must be signed in to change notification settings - Fork 1
/
games.menu
executable file
·64 lines (52 loc) · 1.61 KB
/
games.menu
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!/bin/bash
# launch games from steam
extra_games=(
minecraft-launcher
)
get_key(){
gawk -F'[[:space:]]' -v key="\"$1\"" '
BEGIN { FPAT = "\"([^\"]+)\""; }
$1 == key {
if (substr($2, 1, 1) == "\"") {
$2 = substr($2, 2, length($2) - 2)
}
print $2
exit(0)
}
END { exit(1); }
'
}
steam_libraries=(
~/.local/share/Steam
)
games="$(
{
for path in "${steam_libraries[@]}"; do
for acf in "$path/steamapps/"*.acf; do
echo -e "$(get_key "name" < "$acf")\t$(get_key "appid" < "$acf")"
done
done
for game in "${extra_games[@]}"; do
if hash "$game" > /dev/null; then
echo -e "$game\t0"
fi
done
} | grep -Ev '(Proton|Redistributable|Linux)')"
[[ ! "$games" ]] && notify-send -a "Steam" -i "steam" "No games installed" && exit
line="$(echo "$games" | sort | column -ts$'\t' | dmenu -i -l 20 -p "Steam")"
[[ "$line" ]] || exit
id="$(echo "$line" | grep -o '[0-9]*$')"
name="$(echo "${line//$id/}" | awk '{$1=$1};1')"
icon='steam'
if [[ "$id" -gt 0 ]]; then
game_icon=~/.local/share/Steam/appcache/librarycache/${id}_logo.png
[[ -f "$game_icon" ]] && icon="$game_icon"
notify-send -a "Steam" -i "$icon" "Launching Game" "$name"
steam -applaunch "$id"
else
game_icon="$(find /usr/share/icons | grep "$name" | head -n 1)"
[[ "$game_icon" ]] && icon="$game_icon"
notify-send -a "not Steam" -i "$icon" "Launching Game" "$name"
${name} & disown
fi
# vim: set ft=bash: