diff --git a/ansible/files/game_station/system/jupiter-biosupdate b/ansible/files/game_station/bin/system/jupiter-biosupdate similarity index 100% rename from ansible/files/game_station/system/jupiter-biosupdate rename to ansible/files/game_station/bin/system/jupiter-biosupdate diff --git a/ansible/files/game_station/system/launch_desktop.sh b/ansible/files/game_station/bin/system/launch_desktop.sh similarity index 100% rename from ansible/files/game_station/system/launch_desktop.sh rename to ansible/files/game_station/bin/system/launch_desktop.sh diff --git a/ansible/files/game_station/system/launch_kde.sh b/ansible/files/game_station/bin/system/launch_kde.sh similarity index 100% rename from ansible/files/game_station/system/launch_kde.sh rename to ansible/files/game_station/bin/system/launch_kde.sh diff --git a/ansible/files/game_station/system/launch_session.sh b/ansible/files/game_station/bin/system/launch_session.sh similarity index 96% rename from ansible/files/game_station/system/launch_session.sh rename to ansible/files/game_station/bin/system/launch_session.sh index 5e42106..959e2c1 100644 --- a/ansible/files/game_station/system/launch_session.sh +++ b/ansible/files/game_station/bin/system/launch_session.sh @@ -36,6 +36,8 @@ start_gamescope() { log "HDR disabled, no HDR flag added" fi + env | tee -a "$LOG_FILE" + # Build gamescope argument array for safe quoting and readability GAMESCOPE_ARGS=( --generate-drm-mode fixed @@ -82,10 +84,7 @@ start_kwin() { exec dbus-run-session -- "$KWIN_BIN" ${KWIN_ARGS} "$@" >>"$LOG_FILE" 2>&1 } - export XDG_SEAT=seat0 -export XDG_RUNTIME_DIR=/run/user/$(id -u) -export DBUS_SESSION_BUS_ADDRESS=unix:path=$XDG_RUNTIME_DIR/bus if [[ -f "$HOME/.desktop-session-plasma" ]]; then log "Plasma session selected." diff --git a/ansible/files/game_station/system/launch_steam.sh b/ansible/files/game_station/bin/system/launch_steam.sh similarity index 100% rename from ansible/files/game_station/system/launch_steam.sh rename to ansible/files/game_station/bin/system/launch_steam.sh diff --git a/ansible/files/game_station/system/steamos-select-branch b/ansible/files/game_station/bin/system/steamos-select-branch similarity index 100% rename from ansible/files/game_station/system/steamos-select-branch rename to ansible/files/game_station/bin/system/steamos-select-branch diff --git a/ansible/files/game_station/system/steamos-session-select b/ansible/files/game_station/bin/system/steamos-session-select similarity index 100% rename from ansible/files/game_station/system/steamos-session-select rename to ansible/files/game_station/bin/system/steamos-session-select diff --git a/ansible/files/game_station/system/steamos-update b/ansible/files/game_station/bin/system/steamos-update similarity index 100% rename from ansible/files/game_station/system/steamos-update rename to ansible/files/game_station/bin/system/steamos-update diff --git a/ansible/files/game_station/bin/system/steamos.sh b/ansible/files/game_station/bin/system/steamos.sh new file mode 100644 index 0000000..d74d51d --- /dev/null +++ b/ansible/files/game_station/bin/system/steamos.sh @@ -0,0 +1,4 @@ +#!/bin/bash +set -euo pipefail + +systemctl --user start steamos.target \ No newline at end of file diff --git a/ansible/files/game_station/user/launch_genesis.sh b/ansible/files/game_station/bin/user/launch_genesis.sh similarity index 100% rename from ansible/files/game_station/user/launch_genesis.sh rename to ansible/files/game_station/bin/user/launch_genesis.sh diff --git a/ansible/files/game_station/user/launch_ppspp.sh b/ansible/files/game_station/bin/user/launch_ppspp.sh similarity index 100% rename from ansible/files/game_station/user/launch_ppspp.sh rename to ansible/files/game_station/bin/user/launch_ppspp.sh diff --git a/ansible/files/game_station/user/launch_rpcs3.sh b/ansible/files/game_station/bin/user/launch_rpcs3.sh similarity index 100% rename from ansible/files/game_station/user/launch_rpcs3.sh rename to ansible/files/game_station/bin/user/launch_rpcs3.sh diff --git a/ansible/files/game_station/user/launch_snes.sh b/ansible/files/game_station/bin/user/launch_snes.sh similarity index 100% rename from ansible/files/game_station/user/launch_snes.sh rename to ansible/files/game_station/bin/user/launch_snes.sh diff --git a/ansible/files/game_station/user/update_roms.sh b/ansible/files/game_station/bin/user/update_roms.sh similarity index 100% rename from ansible/files/game_station/user/update_roms.sh rename to ansible/files/game_station/bin/user/update_roms.sh diff --git a/ansible/files/game_station/systemd/user/session.service b/ansible/files/game_station/systemd/user/session.service index e6f3c7f..35cdb6a 100644 --- a/ansible/files/game_station/systemd/user/session.service +++ b/ansible/files/game_station/systemd/user/session.service @@ -1,10 +1,7 @@ [Unit] -Description=User session service -After=graphical-session.target systemd-user-sessions.service +Description=User graphical session service +After=steamos.target [Service] ExecStart=/usr/bin/bash /usr/local/bin/launch_session.sh Restart=on-failure - -[Install] -WantedBy=default.target \ No newline at end of file diff --git a/ansible/files/game_station/systemd/user/steamos.service b/ansible/files/game_station/systemd/user/steamos.service new file mode 100644 index 0000000..53514db --- /dev/null +++ b/ansible/files/game_station/systemd/user/steamos.service @@ -0,0 +1,10 @@ +[Unit] +Description=SteamOS user graphical session service +After=graphical-session.target systemd-user-sessions.service + +[Service] +ExecStart=/usr/bin/bash /usr/local/bin/steamos.sh +Restart=on-failure + +[Install] +WantedBy=default.target \ No newline at end of file diff --git a/ansible/files/game_station/systemd/user/steamos.target b/ansible/files/game_station/systemd/user/steamos.target new file mode 100644 index 0000000..4ded1f3 --- /dev/null +++ b/ansible/files/game_station/systemd/user/steamos.target @@ -0,0 +1,15 @@ +[Unit] +Description=SteamOS Target +Requires=graphical-session.target +BindsTo=graphical-session.target +After=graphical-session.target +PropagatesStopTo=graphical-session.target + +Requires=session.service +BindsTo=session.service + +# Wants=ibus-gamescope.service +# Wants=steam-notif-daemon.service +# Wants=gamescope-xbindkeys.service +# Wants=galileo-mura-setup.service +# Wants=gamescope-mangoapp.service diff --git a/ansible/playbook_game_station.yml b/ansible/playbook_game_station.yml index f0437ca..5a4a5a0 100644 --- a/ansible/playbook_game_station.yml +++ b/ansible/playbook_game_station.yml @@ -86,9 +86,34 @@ enabled: true state: started - - name: Enable wake-on-lan on primary network interface + - name: Determine default network interface + ansible.builtin.set_fact: + primary_iface: "{{ ansible_default_ipv4.interface }}" + + - name: Get NetworkManager connection name for primary interface become: true - ansible.builtin.command: ethtool -s $(ip route show default | awk '/default/ {print $5}') wol g + ansible.builtin.command: > + bash -lc "nmcli -t -f NAME,DEVICE,TYPE c show --active | + awk -F: -v IF='{{ primary_iface }}' '$2==IF && $3==\"802-3-ethernet\"{print $1; exit}'" + register: nm_conn_name + changed_when: false + failed_when: nm_conn_name.stdout == "" + + - name: Ensure WOL is persistent (magic) on the NM connection + become: true + ansible.builtin.shell: > + set -euo pipefail; + cur=$(nmcli -g 802-3-ethernet.wake-on-lan connection show "{{ nm_conn_name.stdout }}" | tr -d '[:space:]'); + if [ "$cur" != "magic" ]; then + nmcli connection modify "{{ nm_conn_name.stdout }}" 802-3-ethernet.wake-on-lan magic; + echo changed; + fi + register: nm_wol_set + changed_when: "'changed' in nm_wol_set.stdout" + + - name: Apply WOL for current boot + become: true + ansible.builtin.command: "ethtool -s {{ primary_iface }} wol g" changed_when: false failed_when: false @@ -146,7 +171,7 @@ owner: root group: root mode: "0755" - loop: "{{ query('fileglob', 'game_station/system/*') }}" + loop: "{{ query('fileglob', 'game_station/bin/system/*') }}" - name: Create system directories become: true @@ -306,7 +331,7 @@ owner: "{{ user_name }}" group: "{{ user_name }}" mode: "0755" - loop: "{{ query('fileglob', 'game_station/user/*') }}" + loop: "{{ query('fileglob', 'game_station/bin/user/*') }}" - name: Write Gamescope configuration become: true @@ -332,7 +357,7 @@ become: true become_user: "{{ user_name }}" ansible.builtin.systemd: - name: session.service + name: steamos.service enabled: true state: started scope: user