you can now activate a steam managed bottle using "steam:$APPID"
This commit is contained in:
		@@ -21,7 +21,7 @@ void cellar::bottles::switch_active_bottle(int argc, vector<string> argv) {
 | 
			
		||||
 | 
			
		||||
    string homepath = getenv("HOME");
 | 
			
		||||
    string bottlepath = homepath + "/.wine";
 | 
			
		||||
    string targetpath = homepath + "/.local/share/cellar/bottles/" + argv[1];
 | 
			
		||||
    string targetpath = cellar::bottles::resolve_bottle(argv[1]);
 | 
			
		||||
 | 
			
		||||
    file_status targetstatus = symlink_status(targetpath);
 | 
			
		||||
    if (!exists(targetstatus)) {
 | 
			
		||||
 
 | 
			
		||||
@@ -85,13 +85,20 @@ string cellar::bottles::resolve_bottle(string bottlechoice) {
 | 
			
		||||
    if (bottlechoice.substr(0,1) == "/" || bottlechoice.substr(0,1) == ".") { // absolute or relative path
 | 
			
		||||
        result = bottlechoice;
 | 
			
		||||
    } else if (bottlechoice.substr(0,1) == "~") { // "absolute" path in home directory, not expanded by the shell for some reason (i've seen some shit)
 | 
			
		||||
        // this is a naive replacement and will fail if the user tries something like ~nick/.wine
 | 
			
		||||
        // this is a naive replacement and will fail if the user tries something like ~nicole/.wine
 | 
			
		||||
        // i'm figuring at that point if you're doing that, you'll also recognize if your shell
 | 
			
		||||
        // isn't actually expanding your path...
 | 
			
		||||
        bottlechoice.replace(0,1,getenv("HOME"));
 | 
			
		||||
        // or at least you'll think to use verbose mode to make sure it's loading the right directory
 | 
			
		||||
        output::warning("your shell didn't expand your given path properly, doing a naive replacement", true);
 | 
			
		||||
        result = bottlechoice;
 | 
			
		||||
#ifdef ENABLE_STEAM
 | 
			
		||||
    } else if (bottlechoice.substr(0,6) == "steam:") { // steam bottles
 | 
			
		||||
        string str_appid = bottlechoice.substr(6);
 | 
			
		||||
        unsigned long uint_appid = std::stoul(str_appid);
 | 
			
		||||
        auto steambottle = cellar::steam::app_bottle(uint_appid);
 | 
			
		||||
        result = steambottle.path;
 | 
			
		||||
#endif
 | 
			
		||||
    } else {
 | 
			
		||||
        string homepath = getenv("HOME");
 | 
			
		||||
        string fullbottlepath = homepath + "/.local/share/cellar/bottles" + bottlechoice;
 | 
			
		||||
 
 | 
			
		||||
@@ -38,13 +38,24 @@ std::map<std::string, cellar::bottles::Bottle> cellar::steam::get_app_bottles()
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
                auto curbottle = cellar::bottles::Bottle(pth_appid.string());
 | 
			
		||||
                curbottle.set_config("description", str_gamename);
 | 
			
		||||
                auto curbottle = cellar::bottles::Bottle((pth_appid / "pfx").string());
 | 
			
		||||
                curbottle.set_config("name", str_gamename);
 | 
			
		||||
                curbottle.save_config();
 | 
			
		||||
                result[std::string("proton-" + pth_appid.filename().string())] = curbottle;
 | 
			
		||||
                result[std::string("steam:" + pth_appid.filename().string())] = curbottle;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    return result;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
cellar::bottles::Bottle cellar::steam::app_bottle(unsigned appid) {
 | 
			
		||||
    string str_appid = std::to_string(appid);
 | 
			
		||||
    string str_prefix = std::string("steam:") + str_appid;
 | 
			
		||||
    auto steambottles = get_app_bottles();
 | 
			
		||||
    if (steambottles.find(str_prefix) == steambottles.end()) {
 | 
			
		||||
        throw std::range_error("steam is not currently managing a valid prefix for " + std::to_string(appid));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    return steambottles.at(str_prefix);
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user