From f3bb9ef2c601991555ca9297c38c2238b48355bd Mon Sep 17 00:00:00 2001 From: "Ruan E. Formigoni" <ruanformigoni@gmail.com> Date: Fri, 18 Oct 2024 14:49:17 -0300 Subject: [PATCH] Updated steam example --- examples/steam.sh | 67 ++++++++++++++++++++++++++++++----------------- 1 file changed, 43 insertions(+), 24 deletions(-) diff --git a/examples/steam.sh b/examples/steam.sh index dab9f4e..7aa8732 100755 --- a/examples/steam.sh +++ b/examples/steam.sh @@ -1,76 +1,95 @@ -#!/bin/bash +#!/bin/sh set -e -function _die() +_die() { echo "$*" >&2 kill -s TERM "$$" } -function _requires() +_requires() { for i; do - command -v "$i" &>/dev/null || _die "Dependency '$i' not found, please install it separately" + command -v "$i" 1>/dev/null 2>/dev/null || _die "Dependency '$i' not found, please install it separately" done } -function _main() +_main() { - _requires "tar" "wget" "xz" + _requires "wget" mkdir -p build && cd build # Use jq to fetch latest flatimage version from github mkdir -p bin - export PATH="$(pwd)/bin:$PATH" - wget -q --show-progress --progress=dot:binary -O bin/jq "https://github.com/jqlang/jq/releases/download/jq-1.7/jq-linux-amd64" + [ -f "bin/jq" ] || wget -O bin/jq "https://github.com/jqlang/jq/releases/download/jq-1.7/jq-linux-amd64" + [ -f "bin/xz" ] || wget -O bin/xz "https://github.com/ruanformigoni/xz-static-musl/releases/download/fec8a15/xz" + [ -f "bin/busybox" ] || wget -O bin/busybox "https://github.com/ruanformigoni/busybox-static-musl/releases/download/7e2c5b6/busybox-x86_64" + ln -sf busybox bin/tar chmod +x ./bin/* + export PATH="$(pwd)/bin:$PATH" # Download flatimage - local image="./bin/arch.flatimage" - wget -q --show-progress --progress=dot:mega -O "$image" "https://github.com/ruanformigoni/flatimage/releases/download/v1.0.2/arch.flatimage" - chmod +x "$image" + IMAGE="./bin/arch.flatimage" + [ -f "$IMAGE" ] || wget -O "$IMAGE" "https://github.com/ruanformigoni/flatimage/releases/download/v1.0.2/arch.flatimage" + chmod +x "$IMAGE" # Enable network - "$image" fim-perms set network + "$IMAGE" fim-perms set network # Update image - "$image" fim-root pacman -Syu --noconfirm + "$IMAGE" fim-root pacman -Syu --noconfirm # Install dependencies ## General - "$image" fim-root pacman -S --noconfirm xorg-server mesa lib32-mesa glxinfo lib32-gcc-libs \ + "$IMAGE" fim-root pacman -S --noconfirm xorg-server mesa lib32-mesa glxinfo lib32-gcc-libs \ gcc-libs pcre freetype2 lib32-freetype2 ## Video AMD/Intel - "$image" fim-root pacman -S --noconfirm xf86-video-amdgpu vulkan-radeon lib32-vulkan-radeon vulkan-tools - "$image" fim-root pacman -S --noconfirm xf86-video-intel vulkan-intel lib32-vulkan-intel vulkan-tools + "$IMAGE" fim-root pacman -S --noconfirm xf86-video-amdgpu vulkan-radeon lib32-vulkan-radeon vulkan-tools + "$IMAGE" fim-root pacman -S --noconfirm xf86-video-intel vulkan-intel lib32-vulkan-intel vulkan-tools # Install steam ## Select the appropriated drivers for your GPU when asked - "$image" fim-root pacman -S --noconfirm steam + "$IMAGE" fim-root pacman -S --noconfirm steam # Clear cache - "$image" fim-root pacman -Scc --noconfirm + "$IMAGE" fim-root pacman -Scc --noconfirm # Set permissions - "$image" fim-perms set media,audio,wayland,xorg,udev,dbus_user,usb,input,gpu,network + "$IMAGE" fim-perms set media,audio,wayland,xorg,udev,dbus_user,usb,input,gpu,network # Configure user name and home directory - "$image" fim-exec mkdir -p /home/steam - "$image" fim-env add 'USER=steam' \ + "$IMAGE" fim-exec mkdir -p /home/steam + "$IMAGE" fim-env add 'USER=steam' \ 'HOME=/home/steam' \ 'XDG_CONFIG_HOME=/home/steam/.config' \ 'XDG_DATA_HOME=/home/steam/.local/share' # Set command to run by default - "$image" fim-boot /usr/bin/steam + "$IMAGE" fim-boot /usr/bin/steam + + # Configure desktop integration + wget -O steam.svg https://upload.wikimedia.org/wikipedia/commons/8/83/Steam_icon_logo.svg + tee steam.json <<-EOF + { + "name": "Steam", + "icon": "./steam.svg", + "categories": ["Game"] + } +EOF + "$IMAGE" fim-desktop setup ./steam.json + "$IMAGE" fim-desktop enable icon,mimetype,entry + + # Notify the application has started + "$IMAGE" fim-notify on # Compress - "$image" fim-commit + "$IMAGE" fim-commit # Copy - cp "$image" ../steam.flatimage + rm -rf ../steam.flatimage + mv "$IMAGE" ../steam.flatimage } _main "$@"