├── install.sh ├── setup.py ├── steamfootbridge ├── __init__.py ├── execute.py ├── download.py ├── setup.py └── config.py ├── documentation ├── roadmap.md └── design.md ├── LICENSE ├── README.md ├── .gitignore └── bin └── steamfootbridge /install.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | python3 setup.py build && sudo python3 setup.py install 4 | -------------------------------------------------------------------------------- /setup.py: -------------------------------------------------------------------------------- 1 | from setuptools import setup 2 | 3 | setup(name='steamfootbridge', 4 | version='0.0.1', 5 | packages=['steamfootbridge'], 6 | scripts=['bin/steamfootbridge'], 7 | install_requires=[ 8 | 'steamodd', 9 | ], 10 | ) 11 | -------------------------------------------------------------------------------- /steamfootbridge/__init__.py: -------------------------------------------------------------------------------- 1 | # SteamFootBridge 2 | # Copyright (c) 2016 Bryan DeGrendel 3 | 4 | from . import config, download, execute, setup 5 | 6 | import pkg_resources 7 | 8 | __app_name__ = "SteamFootBridge" 9 | __version__ = pkg_resources.get_distribution('steamfootbridge').version 10 | -------------------------------------------------------------------------------- /steamfootbridge/execute.py: -------------------------------------------------------------------------------- 1 | # SteamFootBridge 2 | # Copyright (c) 2016 Bryan DeGrendel 3 | 4 | import subprocess 5 | 6 | from . import config 7 | 8 | def do(appid): 9 | print("Executing appid {}".format(appid)) 10 | with config.Configuration() as c: 11 | # TODO: Should we explicitly start Steam if it isn't already running? 12 | subprocess.Popen(["wine", c.get_wine_steam_windows_executable(), "-silent", "-applaunch", 13 | str(appid)]) 14 | -------------------------------------------------------------------------------- /documentation/roadmap.md: -------------------------------------------------------------------------------- 1 | Road Map 2 | -------- 3 | 4 | Future Milestones 5 | ================= 6 | 7 | ### Proof Of Concept 8 | 9 | * Install games in Wine Steam client. 10 | * Run games in Wine Steam client from Linux Steam client. 11 | 12 | ### Internal Test 13 | 14 | * Query list of games from private test web server. 15 | 16 | ### Public Release 17 | 18 | * Query current steam ID. 19 | * Switch to public web server. 20 | 21 | ### Wine Prefixes 22 | 23 | * Setup new Wine prefixes. 24 | * Track list, interface for switching. 25 | 26 | ### GUI 27 | 28 | * GTK Interface. 29 | 30 | Released Milestones 31 | =================== 32 | 33 | -------------------------------------------------------------------------------- /steamfootbridge/download.py: -------------------------------------------------------------------------------- 1 | # SteamFootBridge 2 | # Copyright (c) 2016 Bryan DeGrendel 3 | 4 | import subprocess 5 | 6 | from . import config 7 | 8 | def do(appid): 9 | print("Downloading {}".format(appid)) 10 | with config.Configuration() as c: 11 | # NOTE: It appears that generated shortcuts are little more than 12 | # C:\\Windows\command\start.exe steam://rungameid/ 13 | # Which I'm 90% sure is simply redirecting to Steam.exe steam://rungameid/ 14 | # - possibly with quotation marks. If so, we probably don't need anything beyond this. 15 | # TODO: In the future, SteamFootBridge will cache the list of possible applications and their 16 | # states. Starting a download like this should trigger a refresh. 17 | subprocess.Popen(["wine", c.get_wine_steam_windows_executable(), "-silent", 18 | "steam://install/{}".format(appid)]) 19 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2016 Bryan DeGrendel 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # SteamFootBridge 2 | 3 | For when the [Regular Bridge] [SteamBridge] is too... *sketchy*. 4 | 5 | ## Installation 6 | 7 | **./install.sh**, or normal Python tools via the included setup.py script. 8 | 9 | ## Requirements 10 | 11 | * Linux Steam installed 12 | * Wine Steam installed 13 | * Install to the default Wine prefix, or assure that the WINEPREFIX variable is set. 14 | * Will be started automatically by SteamFootBridge, if necessary. 15 | 16 | ## Usage 17 | 18 | Installation includes an executable Python script named steamfootbridge. 19 | 20 | ~~Run **steamfootbridge setup** to configure the Wine Steam installation~~ Actually a no-op 21 | right now. 22 | 23 | Run **steamfootbridge download (appid)** to download the application corresponding to (appid) 24 | 25 | Run **steamfootbridge execute (appid)** to run the application from within Wine Steam. 26 | This can be added as a shortcut to Linux Steam, and will eventually be automagically added, 27 | based on user settings and what's installed in Wine Steam. Note that at the moment both Steam 28 | clients will inject their own overlays, and it's against the laws of nature to be interacting 29 | with two at a time. For now, disable the overlay in one of the two Steam clients. 30 | 31 | 32 | [SteamBridge]: https://github.com/sirnuke/steambridge 33 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | *$py.class 5 | 6 | # C extensions 7 | *.so 8 | 9 | # Distribution / packaging 10 | .Python 11 | env/ 12 | build/ 13 | develop-eggs/ 14 | dist/ 15 | downloads/ 16 | eggs/ 17 | .eggs/ 18 | lib/ 19 | lib64/ 20 | parts/ 21 | sdist/ 22 | var/ 23 | *.egg-info/ 24 | .installed.cfg 25 | *.egg 26 | 27 | # PyInstaller 28 | # Usually these files are written by a python script from a template 29 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 30 | *.manifest 31 | *.spec 32 | 33 | # Installer logs 34 | pip-log.txt 35 | pip-delete-this-directory.txt 36 | 37 | # Unit test / coverage reports 38 | htmlcov/ 39 | .tox/ 40 | .coverage 41 | .coverage.* 42 | .cache 43 | nosetests.xml 44 | coverage.xml 45 | *,cover 46 | .hypothesis/ 47 | 48 | # Translations 49 | *.mo 50 | *.pot 51 | 52 | # Django stuff: 53 | *.log 54 | local_settings.py 55 | 56 | # Flask stuff: 57 | instance/ 58 | .webassets-cache 59 | 60 | # Scrapy stuff: 61 | .scrapy 62 | 63 | # Sphinx documentation 64 | docs/_build/ 65 | 66 | # PyBuilder 67 | target/ 68 | 69 | # IPython Notebook 70 | .ipynb_checkpoints 71 | 72 | # pyenv 73 | .python-version 74 | 75 | # celery beat schedule file 76 | celerybeat-schedule 77 | 78 | # dotenv 79 | .env 80 | 81 | # virtualenv 82 | venv/ 83 | ENV/ 84 | 85 | # Spyder project settings 86 | .spyderproject 87 | 88 | # Rope project settings 89 | .ropeproject 90 | 91 | .*.sw* 92 | -------------------------------------------------------------------------------- /steamfootbridge/setup.py: -------------------------------------------------------------------------------- 1 | # SteamFootBridge 2 | # Copyright (c) 2016 Bryan DeGrendel 3 | 4 | from . import config 5 | 6 | import steam 7 | 8 | # TODO: Does capitalization mater? 9 | __root_userconfig_key__ = 'UserLocalConfigStore' 10 | __friends_userconfig_key__ = 'friends' 11 | __autologin_friends_key__ = 'AutoSignIntoFriends' 12 | __system_userconfig_key__ = 'system' 13 | __enable_game_overlay_key__ = 'EnableGameOverlay' 14 | 15 | # TODO: Option to disable setting friends autologin 16 | # TODO: Option to disable setting overlay disabled 17 | # TODO: Option to avoid touching the userconfig at all 18 | def do(): 19 | with config.Configuration() as c: 20 | path = c.get_wine_steam_userconfig_filename() 21 | print("Reading {}".format(path)) 22 | 23 | with open(path, 'r') as f: 24 | userconfig = steam.vdf.load(f) 25 | 26 | _base_setup_userconfig(userconfig) 27 | _set_disable_friends_auto_login(userconfig) 28 | _set_disable_overlay(userconfig) 29 | 30 | print("Writing updated {}".format(path)) 31 | with open(path, 'w') as f: 32 | steam.vdf.dump(userconfig, f) 33 | 34 | def _base_setup_userconfig(userconfig): 35 | if not __root_userconfig_key__ in userconfig: 36 | userconfig[__root_userconfig_key__] = {} 37 | root = userconfig[__root_userconfig_key__] 38 | 39 | if not __friends_userconfig_key__ in root: 40 | root[__friends_userconfig_key__] = {} 41 | 42 | if not __system_userconfig_key__ in root: 43 | root[__system_userconfig_key__] = {} 44 | 45 | def _set_disable_friends_auto_login(userconfig): 46 | userconfig[__root_userconfig_key__][__friends_userconfig_key__][__autologin_friends_key__] = '0' 47 | 48 | def _set_disable_overlay(userconfig): 49 | userconfig[__root_userconfig_key__][__system_userconfig_key__][__enable_game_overlay_key__] = '0' 50 | -------------------------------------------------------------------------------- /bin/steamfootbridge: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | import argparse, os, sys 4 | import steamfootbridge 5 | 6 | def error(message): 7 | print("{}: {}".format(steamfootbridge.__app_name__, message)) 8 | exit(1) 9 | 10 | def help(): 11 | print("Command: \t \t \t Description:") 12 | print("\t-v, --version or version : Prints the version of steamfootbridge to the screen") 13 | print("\t-h, --help or help : Prints this screen") 14 | print("\tdownload {steamid} : Downloads the specified app") 15 | print("\texecute {steamid} : Execute the app") 16 | print("\tsetup {steamid} : Set up a new Wineprefix for the specified app") 17 | exit(0) 18 | 19 | def version(): 20 | print("{} {}".format(steamfootbridge.__app_name__, steamfootbridge.__version__)) 21 | exit(0) 22 | 23 | class CLI: 24 | def create_parser(self, command, description): 25 | return argparse.ArgumentParser(prog="{} {}".format(steamfootbridge.__app_name__, command), 26 | description=description) 27 | 28 | def download(self, args): 29 | parser = self.create_parser("download", "Download an application inside Wine Steam") 30 | parser.add_argument("appid", type=int, help="the Steam application's AppID") 31 | args = parser.parse_args(args) 32 | steamfootbridge.download.do(args.appid) 33 | 34 | 35 | def execute(self, args): 36 | parser = self.create_parser("execute", "Execute an application inside Wine Steam") 37 | parser.add_argument("appid", type=int, help="the Steam application's AppID") 38 | args = parser.parse_args(args) 39 | steamfootbridge.execute.do(args.appid) 40 | 41 | def setup(self, args): 42 | parser = self.create_parser("setup", "Setup Wine Steam") 43 | args = parser.parse_args(args) 44 | steamfootbridge.setup.do() 45 | 46 | if len(sys.argv) < 2: 47 | error("Need a command") 48 | 49 | cmd = sys.argv[1].lower() 50 | cli = CLI() 51 | 52 | if cmd == "--help" or cmd == "-h" or cmd == "help": 53 | help() 54 | elif cmd == "--version" or cmd == "-v" or cmd == "version": 55 | version() 56 | elif cmd == "download": 57 | cli.download(sys.argv[2:]) 58 | elif cmd == "execute": 59 | cli.execute(sys.argv[2:]) 60 | elif cmd == "setup": 61 | cli.setup(sys.argv[2:]) 62 | else: 63 | error("Unknown or unrecognized command: {}".format(cmd)) 64 | 65 | -------------------------------------------------------------------------------- /documentation/design.md: -------------------------------------------------------------------------------- 1 | # Design 2 | 3 | ## Goals 4 | 5 | * Do not require any immediate dependencies to run on SteamOS. 6 | * Implement both GUI and console interface within the same executable. 7 | * Implement core functionality as a Python module. 8 | * Implement API for integration into other tools. 9 | * Do not require user to enter any credentials into SteamFootBridge 10 | itself. 11 | * Be fully compliant with Steam terms of service. 12 | * Use official APIs for interaction with Steam, where available. 13 | * Limit all code to Python 2.7. 14 | * Allow users to perform Steam client installation themselves. 15 | * Track list of Wine prefixes, including which one is currently running. 16 | * Automagically install necessary software, if possible. 17 | * Minimize number of prompts, both for setup and execution. 18 | * Allow multiple users to run in same installation. 19 | * Allow mismatch between Linux and Wine user. 20 | * Allow multiple installations of same game across different prefixes. 21 | * Investigate using Winetricks for as many steps as possible. 22 | * Investigate using Wine variants, such as PlayOnLinux or various 23 | CodeWeaver flavors. 24 | 25 | ## Functionality 26 | 27 | ### Determine Steam User 28 | 29 | Query steam IDs of logged in user. Failing that, get list of all users 30 | who have logged in. Failing that, offer interface for determining user 31 | based on Steam Profile ID. 32 | 33 | ### Querying Game List 34 | 35 | Using official Steam Web API, query and locally cache list of games 36 | owned by user. Periodically refresh cache, as well as UI for forcing 37 | a refresh. Do not prevent user from attempting to install games not 38 | reported as owned, using input bar accepting names or application IDs. 39 | 40 | ### Setting up Wine prefixes 41 | 42 | Track list of Wine prefixes, including automagically setting up new ones 43 | on demand. Reference the Linux client settings for configuration of 44 | things like language. Allow user to setup Steam client in the prefix, 45 | if desired, to avoid user having to enter credentials in a software they 46 | didn't initiate. Consider automagically installing frequent dependencies. 47 | 48 | ### Installing Games 49 | 50 | Given a user, Wine prefix, and application id, start the Wine steam client 51 | in silent mode. Install the application using the Steam URL Handler. 52 | Update internal state of application. 53 | 54 | ### Running Games 55 | 56 | Given a user, Wine prefix, and application id, start the Wine steam 57 | client, including stopping a client in the wrong prefix. Fork and 58 | quit from the main thread, to avoid locking the console or an incorrect 59 | "User in non-Steam application" status. Using Steam URL Handler, start 60 | the game. Do not attempt to track what games are currently running, 61 | that's up to the user and Steam to manage. 62 | 63 | ### Uninstall Games 64 | 65 | Installing, but using the uninstall command. 66 | -------------------------------------------------------------------------------- /steamfootbridge/config.py: -------------------------------------------------------------------------------- 1 | # SteamFootBridge 2 | # Copyright (c) 2016 Bryan DeGrendel 3 | 4 | import os, re, shutil, string, subprocess, tempfile 5 | 6 | # NOTE: No explict \"s around the path. They're necessary when running as an actual shell to keep 7 | # the shell from parsing the slash and whatnot, but are actually stripped out when passed 8 | # to Wine. 9 | __wine_registry_steam_key__ = "HKEY_CURRENT_USER\Software\Valve\Steam" 10 | __wine_registry_dump_file__ = "steam-registry.txt" 11 | __wine_registry_steam_executable__ = "SteamExe" 12 | __wine_registry_steam_path__ = "SteamPath" 13 | __wine_steam_user_directories__ = "/userdata" 14 | __wine_steam_userconfig_file__ = "/config/localconfig.vdf" 15 | 16 | class Configuration: 17 | def __init__(self): 18 | pass 19 | 20 | def __enter__(self): 21 | self._temp_directory = tempfile.mkdtemp("steamfootbridge") 22 | self._read_registry_keys() 23 | self._userid = self._determine_current_user() 24 | return self 25 | 26 | def __exit__(self, exception_type, exception_value, traceback): 27 | shutil.rmtree(self._temp_directory) 28 | 29 | def get_wine_steam_windows_executable(self): 30 | return self._wine_steam_windows_executable 31 | 32 | def get_wine_steam_windows_path(self): 33 | return self._wine_steam_windows_path 34 | 35 | def get_wine_steam_path(self): 36 | return self._wine_steam_path 37 | 38 | def get_current_user(self): 39 | return self._userid 40 | 41 | def get_wine_steam_userconfig_filename(self): 42 | return "{}{}/{}{}".format(self.get_wine_steam_path(), __wine_steam_user_directories__, 43 | self._userid, __wine_steam_userconfig_file__) 44 | 45 | def _determine_current_user(self): 46 | directories = os.listdir(self._wine_steam_path.decode() + __wine_steam_user_directories__) 47 | if len(directories) == 0: 48 | raise StandardException("No users found! Have you logged into Wine Steam?") 49 | elif len(directories) > 1: 50 | raise StandardException("Mulitple users found! This will evenatually be handled correctly") 51 | else: 52 | return directories[0] 53 | 54 | 55 | # TODO: This is awfully slow, and it's /probably/ fine to just get the Wine Prefix and do a 56 | # direct search through user.reg - and probably considerably faster. 57 | # TODO: Should handle not finding keys or regedit error or whatever 58 | # TODO: It's probably a good idea to cache this if sticking with regedit, and re-read on request 59 | # or if the path isn't valid 60 | # TODO: Should check to make sure executable actually exists, and path is a directory 61 | def _read_registry_keys(self): 62 | subprocess.call(["regedit", "-E", 63 | "{}/{}".format(self._temp_directory, __wine_registry_dump_file__), 64 | __wine_registry_steam_key__]) 65 | self._wine_steam_windows_path = None 66 | self._wine_steam_windows_executable = None 67 | with open("{}/{}".format(self._temp_directory, __wine_registry_dump_file__)) as f: 68 | for line in f: 69 | result = re.search("\"SteamExe\"=\"(.*)\"", line) 70 | if result: 71 | self._wine_steam_windows_executable = result.group(1) 72 | 73 | result = re.search("\"SteamPath\"=\"(.*)\"", line) 74 | if result: 75 | self._wine_steam_windows_path = result.group(1) 76 | if self._wine_steam_windows_path == None: 77 | raise StandardException("Unable to determine the SteamPath") 78 | if self._wine_steam_windows_executable == None: 79 | raise StandardException("Unable to determine the SteamExe") 80 | self._wine_steam_path = subprocess.check_output(["winepath", 81 | self._wine_steam_windows_path]).strip() 82 | --------------------------------------------------------------------------------