diff --git a/applications/icons/Retro Gaming.png b/applications/icons/Retro Gaming.png new file mode 100644 index 00000000..313172bc Binary files /dev/null and b/applications/icons/Retro Gaming.png differ diff --git a/bin/omarchy b/bin/omarchy index 28bca7fe..bcf820aa 100755 --- a/bin/omarchy +++ b/bin/omarchy @@ -40,6 +40,7 @@ GROUP_DESCRIPTIONS[default]="Default application selection" GROUP_DESCRIPTIONS[dev]="Omarchy development tools" GROUP_DESCRIPTIONS[drive]="Drive selection and encryption" GROUP_DESCRIPTIONS[font]="Font management" +GROUP_DESCRIPTIONS[games]="Game launchers and helpers" GROUP_DESCRIPTIONS[hibernation]="Hibernation setup and removal" GROUP_DESCRIPTIONS[hook]="User hook runner" GROUP_DESCRIPTIONS[hw]="Hardware detection and controls" diff --git a/bin/omarchy-games-retro-cores b/bin/omarchy-games-retro-cores new file mode 100755 index 00000000..a81e9bb0 --- /dev/null +++ b/bin/omarchy-games-retro-cores @@ -0,0 +1,39 @@ +#!/bin/bash + +# omarchy:summary=List installed RetroArch core names + +set -e + +core_dir="/usr/lib/libretro" +preferred_cores=( + "Amstrad CPC|cap32" + "Arcade FBNeo|fbneo" + "Arcade MAME|mame" + "Commodore Amiga|puae" + "Commodore C128|vice_x128" + "Commodore C64|vice_x64" + "Commodore VIC-20|vice_xvic" + "Nintendo DS|desmume" + "Nintendo Game Boy / Color|gambatte" + "Nintendo Game Boy Advance|mgba" + "Nintendo GameCube / Wii|dolphin" + "Nintendo NES / Famicom|mesen" + "Nintendo 64|parallel_n64" + "Nintendo SNES / SFC|snes9x" + "NEC PC Engine / TurboGrafx-16|mednafen_pce_fast" + "NEC PC Engine CD / TurboGrafx-CD|mednafen_pce" + "NEC PC Engine SuperGrafx|mednafen_supergrafx" + "Sega Dreamcast|flycast" + "Sega Mega Drive / Master System / Game Gear|genesis_plus_gx" + "Sega Saturn|kronos" + "Sony PlayStation|mednafen_psx_hw" + "Sony PlayStation Portable|ppsspp" +) + +[[ -d $core_dir ]] || exit 0 + +for preferred_core in "${preferred_cores[@]}"; do + label="${preferred_core%%|*}" + core="${preferred_core#*|}" + [[ -f $core_dir/${core}_libretro.so ]] && printf '%s (%s)\n' "$label" "$core" +done diff --git a/bin/omarchy-games-retro-install b/bin/omarchy-games-retro-install new file mode 100755 index 00000000..6ff7e39f --- /dev/null +++ b/bin/omarchy-games-retro-install @@ -0,0 +1,61 @@ +#!/bin/bash + +# omarchy:summary=Create a desktop launcher for a RetroArch game +# omarchy:args= +# omarchy:examples=omarchy games retro install snes9x ~/Games/roms/snes/game.sfc | omarchy-games-retro-install /usr/lib/libretro/mgba_libretro.so ~/Games/roms/gba/game.gba + +set -e + +if (( $# != 2 )); then + echo "Usage: omarchy-games-retro-install " + echo "Example: omarchy-games-retro-install snes9x ~/Games/roms/snes/game.sfc" + exit 1 +fi + +core="$1" +game_path="$2" + +if [[ ! -f $game_path ]]; then + echo "Game not found: $game_path" + exit 1 +fi + +if [[ $core == */* ]]; then + core_path="$core" +elif [[ $core == *.so ]]; then + core_path="/usr/lib/libretro/$core" +else + core_path="/usr/lib/libretro/${core}_libretro.so" +fi + +if [[ ! -f $core_path ]]; then + echo "Core not found: $core_path" + exit 1 +fi + +game_name=$(printf '%s' "${game_path##*/}" | sed 's/\.[^.]*$//; s/[[:space:]]*([^)]*)//g; s/[[:space:]]\+/ /g; s/^ //; s/ $//' | perl -Mopen=locale -pe 's/(^|[[:space:]])([^[:space:]])/$1\U$2/g') +desktop_name="$game_name" +desktop_id=$(printf '%s' "$desktop_name" | tr '[:upper:]' '[:lower:]' | tr -cs '[:alnum:]' '-' | sed 's/^-//; s/-$//') +desktop_dir="$HOME/.local/share/applications" +desktop_file="$desktop_dir/$desktop_id.desktop" +icon_path="$HOME/.local/share/omarchy/applications/icons/Retro Gaming.png" + +mkdir -p "$desktop_dir" + +cat >"$desktop_file" </dev/null || true + +echo "Created $desktop_file" diff --git a/bin/omarchy-menu b/bin/omarchy-menu index d9583ec8..8418e245 100755 --- a/bin/omarchy-menu +++ b/bin/omarchy-menu @@ -536,6 +536,25 @@ show_install_menu() { esac } +install_retro_game() { + mapfile -t cores < <(omarchy-games-retro-cores) + + if (( ${#cores[@]} == 0 )); then + omarchy-notification-send -g "" "No RetroArch cores found" "/usr/lib/libretro" + return + fi + + core=$(omarchy-menu-select "RetroArch core" "${cores[@]}") || return + [[ -n $core ]] || return + core="${core##*(}" + core="${core%)}" + + game=$(omarchy-menu-file "Retro game" "$HOME/Games/roms" "7z bin ccd chd cue dmg elf fds gb gba gbc iso lha m3u md n64 nds nes pbp sfc smc swc zip z64") || return + [[ -n $game ]] || return + + omarchy-games-retro-install "$core" "$game" +} + show_install_browser_menu() { case $(menu "Install" " Chrome\n Edge\n Brave\n Brave Origin\n Firefox\n󰖟 Zen") in *Chrome*) present_terminal "omarchy-install-browser chrome" ;; @@ -600,8 +619,9 @@ show_install_ai_menu() { } show_install_gaming_menu() { - case $(menu "Install" " Steam\n RetroArch\n󰍳 Minecraft\n󰢹 NVIDIA GeForce NOW\n Xbox Cloud Gaming\n󰂯 Xbox Controller\n󰍹 Moonlight (GameStream)\n Lutris (Battle.net)\n󱓟 Heroic (Epic Games)") in + case $(menu "Install" " Steam\n RetroArch\n RetroArch Game\n󰍳 Minecraft\n󰢹 NVIDIA GeForce NOW\n Xbox Cloud Gaming\n󰂯 Xbox Controller\n󰍹 Moonlight (GameStream)\n Lutris (Battle.net)\n󱓟 Heroic (Epic Games)") in *Steam*) present_terminal omarchy-install-gaming-steam ;; + *"RetroArch Game"*) install_retro_game ;; *RetroArch*) present_terminal omarchy-install-gaming-retroarch ;; *Minecraft*) install_and_launch "Minecraft" "minecraft-launcher" "minecraft-launcher" ;; *GeForce*) present_terminal omarchy-install-gaming-geforce-now ;;