Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add snap support for linux #30

Merged
merged 1 commit into from
Aug 5, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,8 @@ use winreg::{
// TODO: shouldn't be needed?
#[cfg(not(target_os = "windows"))]
extern crate dirs;
#[cfg(target_os = "linux")]
use std::env;

// TODO: rework all of these re-exports
// TODO: keep these errors in a separate module
Expand Down Expand Up @@ -269,6 +271,10 @@ impl SteamDir {
fn locate_steam_dir() -> Option<PathBuf> {
// Steam's installation location is pretty easy to find on Linux, too, thanks to the symlink in $USER
let home_dir = dirs::home_dir()?;
let snap_dir = match env::var("SNAP_USER_DATA") {
Ok(snap_dir) => PathBuf::from(snap_dir),
Err(_) => home_dir.join("snap"),
};

let steam_paths = vec![
// Flatpak steam install directories
Expand All @@ -280,6 +286,10 @@ impl SteamDir {
home_dir.join(".steam/steam"),
home_dir.join(".steam/root"),
home_dir.join(".steam"),
// Snap steam install directories
snap_dir.join("steam/common/.local/share/Steam"),
snap_dir.join("steam/common/.steam/steam"),
snap_dir.join("steam/common/.steam/root"),
];

steam_paths.into_iter().find(|x| x.is_dir())
Expand Down