Hermes 0.7.0
Linux game streaming host
Loading...
Searching...
No Matches
desktop_steam.h File Reference

Find the user's Steam client, native or Flatpak. More...

#include <algorithm>
#include <cctype>
#include <filesystem>
#include <fstream>
#include <optional>
#include <string>
#include <string_view>
#include <sys/types.h>
Include dependency graph for desktop_steam.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  platf::desktop_steam::client_t

Functions

std::string platf::desktop_steam::detail::first_line (const std::filesystem::path &file)
bool platf::desktop_steam::detail::owned_by (const std::filesystem::path &entry, uid_t uid)
bool platf::desktop_steam::detail::is_client (const std::filesystem::path &entry)
bool platf::desktop_steam::detail::in_flatpak (const std::filesystem::path &entry)
std::optional< client_t > platf::desktop_steam::find (const std::filesystem::path &proc, uid_t uid, const std::filesystem::path &pid_file, std::string_view own_cgroup)
 The user's running Steam client.

Variables

constexpr std::string_view platf::desktop_steam::flatpak_id = "com.valvesoftware.Steam"
 The Flatpak's application ID.

Detailed Description

Find the user's Steam client, native or Flatpak.

Definition in file desktop_steam.h.

Function Documentation

◆ find()

std::optional< client_t > platf::desktop_steam::find ( const std::filesystem::path & proc,
uid_t uid,
const std::filesystem::path & pid_file,
std::string_view own_cgroup )
inline

The user's running Steam client.

~/.steam/steam.pid names the native client. A Flatpak's pid file is in its own home, ~/.var/app/com.valvesoftware.Steam, and holds the pid in the sandbox's pid namespace, which means nothing outside it; so this looks through /proc for the client instead.

Parameters
procThe proc file system.
uidThe user whose Steam to find.
pid_fileThe native pid file, tried first; empty to skip it.
own_cgroupHermes' own cgroup when it runs as a service; a Steam under it is one Hermes started, not the desktop's.

Definition at line 86 of file desktop_steam.h.

◆ first_line()

std::string platf::desktop_steam::detail::first_line ( const std::filesystem::path & file)
inline

Definition at line 28 of file desktop_steam.h.

◆ in_flatpak()

bool platf::desktop_steam::detail::in_flatpak ( const std::filesystem::path & entry)
inline

Definition at line 63 of file desktop_steam.h.

◆ is_client()

bool platf::desktop_steam::detail::is_client ( const std::filesystem::path & entry)
inline

The client is an executable named steam under the Steam directory: steamrt64/steam for the 64-bit client, ubuntu12_32/steam before it. The steam launcher is a shell script with the same process name, but its executable is the shell, so the executable's name tells them apart.

Definition at line 54 of file desktop_steam.h.

◆ owned_by()

bool platf::desktop_steam::detail::owned_by ( const std::filesystem::path & entry,
uid_t uid )
inline

Definition at line 35 of file desktop_steam.h.

Variable Documentation

◆ flatpak_id

std::string_view platf::desktop_steam::flatpak_id = "com.valvesoftware.Steam"
inlineconstexpr

The Flatpak's application ID.

Definition at line 19 of file desktop_steam.h.