44MODE=${1}
55scrDir=$( dirname " $( realpath " $0 " ) " )
66source $scrDir /globalcontrol.sh
7- ThemeSet=" ${confDir} /hypr/themes/theme.conf"
7+ # ThemeSet="${confDir}/hypr/themes/theme.conf"
88
99if [[ " $MODE " =~ ^[0-9]+$ ]]; then
10- RofiConf=" gamelauncher_${MODE} "
10+ RofiConf=" gamelauncher_${MODE} "
1111else
12- RofiConf=" ${MODE:- $ROFI_GAMELAUNCHER_STYLE } "
12+ RofiConf=" ${MODE:- $ROFI_GAMELAUNCHER_STYLE } "
1313fi
1414RofiConf=${RofiConf:- " gamelauncher_5" }
1515
@@ -19,69 +19,71 @@ icon_border=$((elem_border - 3))
1919r_override=" element{border-radius:${elem_border} px;} element-icon{border-radius:${icon_border} px;}"
2020
2121fn_steam () {
22- # check steam mount paths
23- SteamPaths=$( grep ' "path"' $SteamLib | awk -F ' "' ' {print $4}' )
24- ManifestList=$( find $SteamPaths /steamapps/ -type f -name " appmanifest_*.acf" 2> /dev/null)
25-
26- # read installed games
27- GameList=$( echo " $ManifestList " | while read acf; do
28- appid=$( grep ' "appid"' $acf | cut -d ' "' -f 4)
29- if [ -f ${SteamThumb} /${appid} _library_600x900.jpg ]; then
30- game=$( grep ' "name"' $acf | cut -d ' "' -f 4)
31- echo " $game |$appid "
32- else
33- continue
34- fi
35- done | sort)
36-
37- # launch rofi menu
38- RofiSel=$( echo " $GameList " | while read acf; do
39- appid=$( echo $acf | cut -d ' |' -f 2)
40- game=$( echo $acf | cut -d ' |' -f 1)
41- echo -en " $game \x00icon\x1f${SteamThumb} /${appid} _library_600x900.jpg\n"
42- done | rofi -dmenu \
43- -theme-str " ${r_override} " \
44- -config $RofiConf )
45-
46- # launch game
47- if [ ! -z " $RofiSel " ]; then
48- launchid=$( echo " $GameList " | grep " $RofiSel " | cut -d ' |' -f 2)
49- ${steamlaunch} -applaunch " ${launchid} [gamemoderun %command%]" &
50- # dunstify "HyDE Alert" -a "Launching ${RofiSel}..." -i ${SteamThumb}/${launchid}_header.jpg -r 91190 -t 2200
51- notify-send -a " HyDE Alert" -i " ${SteamThumb} /${launchid} _header.jpg" " Launching ${RofiSel} ..."
52-
22+ # check steam mount paths
23+ SteamPaths=$( grep ' "path"' $SteamLib | awk -F ' "' ' {print $4}' )
24+ ManifestList=$( find " ${SteamPaths} /steamapps/" -type f -name " appmanifest_*.acf" 2> /dev/null)
25+ # read installed games
26+ GameList=$( echo " $ManifestList " | while read acf; do
27+ appid=$( grep ' "appid"' $acf | cut -d ' "' -f 4)
28+ if [ -f ${SteamThumb} /${appid} /library_600x900.jpg ]; then
29+ game=$( grep ' "name"' $acf | cut -d ' "' -f 4)
30+ echo " $game |$appid "
31+ else
32+ continue
5333 fi
34+ done | sort)
35+
36+ # launch rofi menu
37+ RofiSel=$(
38+ echo " $GameList " | while read acf; do
39+ appid=$( echo " ${acf} " | cut -d ' |' -f 2)
40+ game=$( echo " ${acf} " | cut -d ' |' -f 1)
41+ printf " %s\x00icon\x1f${SteamThumb} /${appid} /library_600x900.jpg\n" " ${game} " >&2
42+ printf " %s\x00icon\x1f${SteamThumb} /${appid} /library_600x900.jpg\n" " ${game} "
43+ done | rofi -dmenu \
44+ -theme-str " ${r_override} " \
45+ -config $RofiConf
46+ )
47+
48+ # launch game
49+ if [ -n " $RofiSel " ]; then
50+ launchid=$( echo " $GameList " | grep " $RofiSel " | cut -d ' |' -f 2)
51+ ${steamlaunch} -applaunch " ${launchid} [gamemoderun %command%]" &
52+ # dunstify "HyDE Alert" -a "Launching ${RofiSel}..." -i ${SteamThumb}/${launchid}_header.jpg -r 91190 -t 2200
53+ notify-send -a " HyDE Alert" -i " ${SteamThumb} /${launchid} _header.jpg" " Launching ${RofiSel} ..."
54+
55+ fi
5456}
5557
5658fn_lutris () {
57- [ ! -e " ${icon_path} " ] && icon_path=" ${HOME} /.local/share/lutris/coverart"
58- [ ! -e " ${icon_path} " ] && icon_path=" ${HOME} /.cache/lutris/coverart"
59- meta_data=" /tmp/hyprdots-$( id -u) -lutrisgames.json"
59+ [ ! -e " ${icon_path} " ] && icon_path=" ${HOME} /.local/share/lutris/coverart"
60+ [ ! -e " ${icon_path} " ] && icon_path=" ${HOME} /.cache/lutris/coverart"
61+ meta_data=" /tmp/hyprdots-$( id -u) -lutrisgames.json"
6062
61- # Retrieve the list of games from Lutris in JSON format
62- # TODO Only call this if new apps are installed...
63- # [ ! -s "${meta_data}" ] &&
64- notify-send -a " HyDE Alert" " Please wait... " -t 4000
63+ # Retrieve the list of games from Lutris in JSON format
64+ # TODO Only call this if new apps are installed...
65+ # [ ! -s "${meta_data}" ] &&
66+ notify-send -a " HyDE Alert" " Please wait... " -t 4000
6567
66- cat << EOF
68+ cat << EOF
6769"Fetching Lutris Games..."
6870
6971On error, please try to run the following command: '${run_lutris} " -j -l'
7072
7173EOF
7274
73- eval " ${run_lutris} " -j -l 2> /dev/null | jq --arg icons " $icon_path /" --arg prefix " .jpg" ' .[] |= . + {"select": (.name + "\u0000icon\u001f" + $icons + .slug + $prefix)}' > " ${meta_data} "
74-
75- [ ! -s " ${meta_data} " ] && notify-send -a " HyDE Alert" " Cannot Fetch Lutris Games!" && exit 1
76- CHOICE=$(
77- jq -r ' .[].select' " ${meta_data} " | rofi -dmenu -p Lutris \
78- -theme-str " ${r_override} " \
79- -config " ${RofiConf} "
80- )
81- [ -z " $CHOICE " ] && exit 0
82- SLUG=$( jq -r --arg choice " $CHOICE " ' .[] | select(.name == $choice).slug' " ${meta_data} " )
83- notify-send -a " HyDE Alert" -i " ${icon_path} /${SLUG} .jpg" " Launching ${CHOICE} ..."
84- exec xdg-open " lutris:rungame/${SLUG} "
75+ eval " ${run_lutris} " -j -l 2> /dev/null | jq --arg icons " $icon_path /" --arg prefix " .jpg" ' .[] |= . + {"select": (.name + "\u0000icon\u001f" + $icons + .slug + $prefix)}' > " ${meta_data} "
76+
77+ [ ! -s " ${meta_data} " ] && notify-send -a " HyDE Alert" " Cannot Fetch Lutris Games!" && exit 1
78+ CHOICE=$(
79+ jq -r ' .[].select' " ${meta_data} " | rofi -dmenu -p Lutris \
80+ -theme-str " ${r_override} " \
81+ -config " ${RofiConf} "
82+ )
83+ [ -z " $CHOICE " ] && exit 0
84+ SLUG=$( jq -r --arg choice " $CHOICE " ' .[] | select(.name == $choice).slug' " ${meta_data} " )
85+ notify-send -a " HyDE Alert" -i " ${icon_path} /${SLUG} .jpg" " Launching ${CHOICE} ..."
86+ exec xdg-open " lutris:rungame/${SLUG} "
8587}
8688
8789# Handle if flatpak or pkgmgr
@@ -92,22 +94,22 @@ icon_path="${HOME}/.var/app/net.lutris.Lutris/data/lutris/coverart/"
9294[ -z " ${run_lutris} " ] && (pkg_installed ' lutris' ) && run_lutris=" lutris"
9395
9496if [ -z " ${run_lutris} " ] || echo " $* " | grep -q " steam" ; then
95- # set steam library
96- if pkg_installed steam; then
97- SteamLib=" ${XDG_DATA_HOME:- $HOME / .local/ share} /Steam/config/libraryfolders.vdf"
98- SteamThumb=" ${XDG_DATA_HOME:- $HOME / .local/ share} /Steam/appcache/librarycache"
99- steamlaunch=" steam"
100- else
101- SteamLib=" $HOME /.var/app/com.valvesoftware.Steam/.local/share/Steam/config/libraryfolders.vdf"
102- SteamThumb=" $HOME /.var/app/com.valvesoftware.Steam/.local/share/Steam/appcache/librarycache"
103- steamlaunch=" flatpak run com.valvesoftware.Steam"
104- fi
105-
106- if [ ! -f $SteamLib ] || [ ! -d $SteamThumb ]; then
107- notify-send -a " HyDE Alert" " Steam library not found!"
108- exit 1
109- fi
110- fn_steam
97+ # set steam library
98+ if pkg_installed steam; then
99+ SteamLib=" ${XDG_DATA_HOME:- $HOME / .local/ share} /Steam/config/libraryfolders.vdf"
100+ SteamThumb=" ${XDG_DATA_HOME:- $HOME / .local/ share} /Steam/appcache/librarycache"
101+ steamlaunch=" steam"
102+ else
103+ SteamLib=" $HOME /.var/app/com.valvesoftware.Steam/.local/share/Steam/config/libraryfolders.vdf"
104+ SteamThumb=" $HOME /.var/app/com.valvesoftware.Steam/.local/share/Steam/appcache/librarycache"
105+ steamlaunch=" flatpak run com.valvesoftware.Steam"
106+ fi
107+
108+ if [ ! -f $SteamLib ] || [ ! -d $SteamThumb ]; then
109+ notify-send -a " HyDE Alert" " Steam library not found!"
110+ exit 1
111+ fi
112+ fn_steam
111113else
112- fn_lutris
114+ fn_lutris
113115fi
0 commit comments