5 namespace GameHub
.Utils
11 public class Settings
: Granite
.Services
.Settings
13 public string steam_home
{ get; set; }
14 public string gog_games
{ get; set; }
15 public string humble_games
{ get; set; }
19 base(ProjectConfig
.PROJECT_NAME
+ ".paths");
22 private static Settings? instance
;
23 public static unowned Settings
get_instance()
27 instance
= new
Settings();
35 public const string Home
= "~/.cache/com.github.tkashkin.gamehub";
37 public const string Cookies
= FSUtils
.Paths
.Cache
.Home
+ "/cookies";
38 public const string Images
= FSUtils
.Paths
.Cache
.Home
+ "/images";
40 public const string GamesDB
= FSUtils
.Paths
.Cache
.Home
+ "/games.db";
45 public static string Home
{ get { return FSUtils
.Paths
.Settings
.get_instance().steam_home
; } }
46 public static string Config
{ owned
get { return FSUtils
.Paths
.Steam
.Home
+ "/steam/config"; } }
47 public static string LoginUsersVDF
{ owned
get { return FSUtils
.Paths
.Steam
.Config
+ "/loginusers.vdf"; } }
49 public static string SteamApps
{ owned
get { return FSUtils
.Paths
.Steam
.Home
+ "/steam/steamapps"; } }
50 public static string LibraryFoldersVDF
{ owned
get { return FSUtils
.Paths
.Steam
.SteamApps
+ "/libraryfolders.vdf"; } }
55 public static string Games
{ get { return FSUtils
.Paths
.Settings
.get_instance().gog_games
; } }
56 public static string Installers
{ owned
get { return FSUtils
.Paths
.GOG
.Games
+ "/.installers"; } }
61 public static string Games
{ get { return FSUtils
.Paths
.Settings
.get_instance().humble_games
; } }
62 public static string Installers
{ owned
get { return FSUtils
.Paths
.Humble
.Games
+ "/.installers"; } }
66 public static string expand(string path
, string file
="")
68 return path
.replace("~", Environment
.get_home_dir()) + (file
!= "" ?
"/" + file
: "");
71 public static File
file(string path
, string file
="")
73 return File
.new_for_path(FSUtils
.expand(path
, file
));
76 public static File?
mkdir(string path
, string file
="")
80 var dir
= FSUtils
.file(path
, file
);
81 if(!dir
.query_exists()) dir
.make_directory_with_parents();
91 public static void make_dirs()
93 mkdir(FSUtils
.Paths
.Cache
.Home
);
94 mkdir(FSUtils
.Paths
.Cache
.Images
);
96 var cache
= FSUtils
.expand(FSUtils
.Paths
.GOG
.Installers
, "{*~,.goutputstream-*}");
97 Utils
.run(@
"bash -c 'rm $(cache)'");
98 cache
= FSUtils
.expand(FSUtils
.Paths
.Humble
.Installers
, "{*~,.goutputstream-*}");
99 Utils
.run(@
"bash -c 'rm $(cache)'");
102 public static Pixbuf?
get_icon(string name
, int size
=48)
106 return new Pixbuf
.from_resource_at_scale(@
"/com/github/tkashkin/gamehub/icons/$(name).svg", size
, size
, true);