Skip to content

Commit

Permalink
Add Snap support for linux (#30)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jan200101 authored Aug 5, 2023
1 parent 2785a53 commit ace7fca
Showing 1 changed file with 10 additions and 0 deletions.
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

0 comments on commit ace7fca

Please sign in to comment.