[
  {
    "path": ".gitignore",
    "content": "# Ignore those random Mac files\n.DS_Store\n\n# Ignore vim swap files\n*.swp\n\n# Ignore Python pyc files\n*.pyc\n\n# Add PyPi files\nbuild/\ndist/\nwal_steam.egg-info/\n"
  },
  {
    "path": "LICENSE",
    "content": "MIT License\n\nCopyright (c) 2017 Dakota Walsh\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n"
  },
  {
    "path": "README.md",
    "content": "# `wal_steam`\n\nA little program that themes the colors for Metro for steam from `wal`or `wpg`. Now with HiDPI support!\n\n![1](https://paste.cf/8653142dd2aac9b734b1cacf85d141315a8d59f2.png)\n\n## About\n\n`wal_steam` is a tiny program that is meant to work with either `wal` or `wpgtk`, by reading the colors they generate and making a color theme for a slightly tweaked version of Metro for Steam.\n\n**Disclaimer:** Steam isn't nearly as \"theme-able\" as it once was. Over the\nyears many of the UI elements that we used to be able to change with themes with\nbe re-written with hard-coding to use steam's default blue theme. As a result\n`wal_steam` has gotten noticably worse since I originally wrote it. I'll accept\npull requests when I have time to test them, but this project is very low\npriority to me since I barely use Steam anymore. I suggest getting your games on\nitch, gog, or humble.\n\n[Wal](https://github.com/dylanaraps/pywal) is a little program for linux that creates a terminal color scheme based on your wallpaper (in addition to being able to set the wallpaper and a few other\ninteresting features).\n\n[Wpgtk](https://github.com/deviantfero/wpgtk) is based on wal, but with the added feature of being able to generate gtk themes with the colors and bring a nice simple ui to wal.\n\n[Metro for steam](http://metroforsteam.com/) is a very nice looking skin for steam. We also add the [community patch](https://steamcommunity.com/groups/metroskin/discussions/0/141136086931804907) which makes the skin render well on linux.\n\n## Install\n\n**Note for Windows users:** You're going to need to install [python 3](https://www.python.org/) then [imagemagick](https://www.imagemagick.org/script/download.php) first. Then search for command prompt, right click it and open as administrator, then run the pip command below but without the sudo part.\n\n### Packages\n\n**Python PIP:** `sudo pip3 install wal-steam`\n\n**Arch Linux AUR:** `yay -S python-wal-steam-git`\n\n### Manual\n\n**Pre-install:** Make sure [Wal](https://github.com/dylanaraps/pywal) or [Wpgtk](https://github.com/deviantfero/wpgtk) is installed and working.\n\n**Install:** `git clone https://github.com/kotajacob/wal_steam.git`\n\n**Post-install:** See the \"Using\" section of this readme.\n\n## Using\n\n**Make sure you've run wal or wpgk at least once to generate the colors and set the wallpaper.**\n\n**Note:** On some distros, notably **Ubuntu** you'll have to run the command python3 instead of python or you'll have an error about failing to import urllib.request. Additionally, OSx users may   need to use the system certificate store (outlined [here](https://stackoverflow.com/questions/41691327/ssl-sslerror-ssl-certificate-verify-failed-certificate-verify-failed-ssl-c)).\n\nIf you cloned the repo all you need to do is run the script with python 3 from wherever you downloaded it.\n\nExample:\n\n`wal_steam -w`\n\n```\nUsage:\n  wal_steam.py (-w | -g | -u) [-d]\n  wal_steam.py ( -s ) [\"/home/kota/bin/custom_steam_install/skins/\"]\n  wal_steam.py (-h | --help)\n  wal_steam.py (-v | --version)\n  wal_steam.py (-f | --fonts) [\"Ubuntu, Ubuntu Bold, Ubuntu Medium, Ubuntu Light\"]\n\nOptions:\n  -h --help            show this help message and exit\n  -v --version         show version and exit\n  -w                   use wal for colors\n  -g                   use wpg for colors\n  -u                   force update cache and config file\n  -d                   apply HiDPI community patch\n  -s \"/steam/skins\"    specify a custom steam skins folder to use\n  -f --fonts           specify custom fonts\n  -a --attempts        specify the max number of patch download attempts (DEFAULT=5)\n```\n"
  },
  {
    "path": "docs/colors.md",
    "content": "# Colors.styles descriptions\nFor wal_steam, colors.styles is one of the most important files, it stores all the color variables that are used elsewhere in steam, and also controls the colors of the majority of the steam client and the ingame overlay.\n\n## Variables\nIn the main part of the code, there are a bunch of variables that appear to not be used anywhere in the metro for steam directory. At this point it is unknown if these are being used anywhere, so we aren't going to touch them\n\n## Items\nThis is the section that the first couple versions of wal_steam will be focusing on changing. It is located after the variables. It contains items and their color values, stored in an rgba format.\n\nIn the unnoficial patch for metro for steam, there are some 'extras' that are included. Some of these extras must be installed for some items to be colored. For instance, to have the scrollbars be a different color, you will need to install the 'accent scrollbars' extra.\n\n# Item descriptions\nFocus: The highlight color of selected games in the game launch panel\n\nFriends_InGame: The text color of a friends name while they are in a game\n\nFriends_Online: The text color of a friends name while they are online\n\nFrameBorder: The color of the borders at the edge of each window, also serperates the header from the rest of a window\n\nGameList: background color of the game list on the left side of the library\n\nDividers: color of dividers in dropdown menus\n\nSeperators: color of column seperators in places like the dlc information panel in the details of a game\n\nOverlayBackground: color of the background of the in game overlay\n\nOverlay Panels: Overlay item backgrounds (friends, guides, etc...)\n\nOverlayClock: color of clock in the overlay\n\nOverlaySideButtons: Color of buttons on the right side of the overlay (web browser, music, settings)\n\nOverlaysideButtons_h: Color of buttons described above when you hover the mouse over them\n\nTextEntry: Background color of any text box in the steam client (filter games, search friends, chat windoww)\n\n\nHeader_Dark: Color of window header\n\nClientBG: Main background color of the client, it also controlls the background color of any categories in the game list\n\n# Controls.styles\nFor right now all we will be editing here is the scrollbar color. In later versions there may be other changes made in this file\n\n# Item descriptions\nScrollBarSlider: Color of scrollbars is defined in 'bgcolor'\n\n"
  },
  {
    "path": "docs/command_line.md",
    "content": "Command Line Options\n====================\n\n--version = print version of wal_steam\n\n-v or --verbose = print more information\n\n-h = print help menu\n\n-w = use wal\n\n-g = use wpg\n\n-c = manually give custom color values\n"
  },
  {
    "path": "docs/locations.md",
    "content": "Locations\n=========\n\nWal\n---\n\nDefault color css file in wal\n\n    ~/.cache/wal/colors.css\n\nWpg\n---\n\nDefault color css file in wpg\n\n    ~/.wallpapers/current.css\n\nMetro for Steam\n---------------\n\nEditable colors file in metro\n\n    ~/.steam/steam/skins/Metro\\ 4.2.4/colors.styles\n"
  },
  {
    "path": "docs/styles.md",
    "content": "# .styles file format\nThey all use tabs to indent\n\nThe first line seems to define what the file relates to. An example of this can be seen in colors.styles, which is included in settings.styles, so it has \"settings.styles\" on the first line (this is mostly speculation, I will update it once I know for sure)\n\nAfter this, any other files that are to be included are defined. This is done by entering 'include \"file\"' inside the first set of brackets\n\nAfter that, there is a word defining what is inside the next set of brackets. From what info I have gathered, it can be either 'styles' or 'colors'. If any other words are entered here, the ui gets very messed up.\n\nFinally, there is another set of brackets inside the first set, which houses the main part of the code.\n \n"
  },
  {
    "path": "setup.py",
    "content": "\"\"\"wal_steam - setup.py\"\"\"\nimport setuptools\n\ntry:\n    import wal_steam\nexcept (ImportError):\n    print(\"error: wal_steam requires Python 3.5 or greater.\")\n    quit(1)\n\nVERSION = wal_steam.VERSION\nDOWNLOAD = \"https://github.com/kotajacob/wal_steam/archive/%s.tar.gz\" % VERSION\n\n\nsetuptools.setup(\n    name=\"wal_steam\",\n    version=VERSION,\n    author=\"Dakota Walsh\",\n    author_email=\"kotawalsh@gmail.com\",\n    description=\"A little program that themes the colors for Metro for steam from wal or wpg. Now with windows support!\",\n    license=\"MIT\",\n    url=\"https://github.com/kotajacob/wal_steam\",\n    download_url=DOWNLOAD,\n    classifiers=[\n        \"Environment :: X11 Applications\",\n        \"License :: OSI Approved :: MIT License\",\n        \"Operating System :: POSIX :: Linux\",\n        \"Programming Language :: Python :: 3.5\",\n        \"Programming Language :: Python :: 3.6\",\n    ],\n    install_requires=\"pywal >= 0.6.7\",\n    scripts=['wal_steam.py'],\n    entry_points={\n        \"console_scripts\": [\"wal-steam=wal_steam:main\"]\n    },\n    python_requires=\">=3.5\",\n    include_package_data=True\n)\n"
  },
  {
    "path": "wal_steam.py",
    "content": "#!/usr/bin/env python3\n\"\"\"\nWal Steam\n\n========================================\noooo    oooo               .\n`888   .8P'              .o8\n 888  d8'     .ooooo.  .o888oo  .oooo.\n 88888[      d88' `88b   888   `P  )88b\n 888`88b.    888   888   888    .oP\"888\n 888  `88b.  888   888   888 . d8(  888\no888o  o888o `Y8bod8P'   \"888\" `Y888\"\"8o\n               @nilsu.org\n=== Copyright (C) 2019  Dakota Walsh ===\n\"\"\"\nimport shutil                             # copying files\nimport os                                 # getting paths\nimport urllib.request                     # downloading the zip files\nimport zipfile                            # extracting the zip files\nimport sys\nimport argparse                           # argument parsing\nimport textwrap\nimport time\nimport re\nfrom distutils.dir_util import copy_tree  # copytree from shutil is broken so use copy_tree\nfrom argparse import RawTextHelpFormatter\n\n# set some variables for the file locations\nHOME_DIR          = os.getenv(\"HOME\", os.getenv(\"USERPROFILE\")) # should be crossplatform\nCACHE_DIR         = os.path.join(HOME_DIR, \".cache\", \"wal_steam\")\nCONFIG_DIR        = os.path.join(HOME_DIR, \".config\", \"wal_steam\")\nSKIN_VERSION      = \"4.4\"\nSKIN_NAME         = \"Metro %s Wal_Mod\" % SKIN_VERSION\nVERSION           = \"1.4\"\nCONFIG_FILE       = \"wal_steam.conf\"\nCOLORS_FILE       = os.path.join(CACHE_DIR, \"custom.styles\")\nCONFIG_URL        = \"https://raw.githubusercontent.com/kotajacob/wal_steam_config/master/wal_steam.conf\"\n\nSTEAM_DIR_OTHER   = os.path.expanduser(\"~/.steam/steam/skins\")\nSTEAM_DIR_OSX     = os.path.expanduser(\"~/Library/Application Support/Steam/Steam.AppBundle/Steam/Contents/MacOS/skins\")\nSTEAM_DIR_UBUNTU  = os.path.expanduser(\"~/.steam/skins\")\nSTEAM_DIR_WINDOWS = \"C:\\Program Files (x86)\\Steam\\skins\"\nWAL_COLORS        = os.path.join(HOME_DIR, \".cache\", \"wal\", \"colors.css\")\nWPG_COLORS        = os.path.join(HOME_DIR, \".config\", \"wpg\", \"formats\", \"colors.css\")\n\nMETRO_URL                 = \"https://github.com/minischetti/metro-for-steam/archive/v%s.zip\" % SKIN_VERSION\nMETRO_ZIP                 = os.path.join(CACHE_DIR, \"metroZip.zip\")\nMETRO_DIR                 = os.path.join(CACHE_DIR, \"metro-for-steam-%s\" % SKIN_VERSION)\nMETRO_COLORS_FILE         = os.path.join(METRO_DIR, \"custom.styles\")\n\nMETRO_PATCH_URL  = \"https://github.com/redsigma/UPMetroSkin/archive/9.1.12.zip\" # A link to the version we've tested rather than the latest, just in case they break things upstream.\nMETRO_PATCH_ZIP  = os.path.join(CACHE_DIR, \"metroPatchZip.zip\")\nMETRO_PATCH_DIR  = os.path.join(CACHE_DIR, \"metroPatchZip\")\nMETRO_PATCH_COPY = os.path.join(METRO_PATCH_DIR, \"UPMetroSkin-9.1.12\", \"Unofficial 4.x Patch\", \"Main Files [Install First]\")\nMETRO_PATCH_HDPI = os.path.join(METRO_PATCH_DIR, \"UPMetroSkin-9.1.12\", \"Unofficial 4.x Patch\", \"Extras\", \"High DPI\", \"Increased fonts\", \"Install\")\nMAX_PATCH_DL_ATTEMPTS = 5\n\n# CLI colour and style sequences\nCLI_RED    = \"\\033[91m\"\nCLI_YELLOW = \"\\033[93m\"\nCLI_BOLD   = \"\\033[1m\"\nCLI_END    = \"\\033[0m\"\n\ndef tupToPrint(tup):\n    tmp = ' '.join(map(str, tup)) # convert the tupple (rgb color) to a string ready to print\n    return tmp\n\ndef setCustomStyles(colors, variables, walColors, alpha, steam_dir, fonts = []):\n    print (\"Patching new colors\")\n\n    # delete the old colors file if present in cache\n    try:\n        os.remove(COLORS_FILE) # just in case it was already there for some reason\n    except FileNotFoundError:\n        print(\"No file to remove\")\n\n    with open(METRO_COLORS_FILE) as f:\n        custom_styles = f.read()\n\n    patches = []\n    ii = 0\n    for ii, i in enumerate(variables):\n        patches.append(\n            '{}=\"{} {}\"'.format(i, tupToPrint(colors[int(walColors[ii])]), alpha[ii])\n        )\n\n    wal_styles = \"\\n\".join(patches)\n    custom_styles = custom_styles.replace(\n        \"}\\n\\nstyles{\", wal_styles + \"}\\n\\nstyles{\")\n\n    if fonts:\n        custom_styles = replaceFonts(custom_styles, fonts)\n\n    with open(COLORS_FILE, \"w\") as f:\n        f.write(custom_styles)\n\n    # now copy it to the proper place based on the os\n    shutil.copy(COLORS_FILE, os.path.join(steam_dir, SKIN_NAME))\n\n    # cleanup by removing generated color files\n    os.remove(COLORS_FILE)\n    print(\n        \"Wal colors are now patched and ready to go\\n\"\n        \"If this is your first run you may have to\\n\"\n        \"enable Metro Wal Mod skin in steam then\\n\"\n        \"simply restart steam!\"\n    )\n\n\ndef replaceFonts(styles, fonts):\n    print(\"Patching custom fonts\")\n\n    # attempt to replace font styles with regular expressions\n    matches = {\n        \"^basefont=\\\"(.+?)\\\"\": \"basefont=\\\"\" + fonts[0] + \"\\\"\",\n        \"^semibold=\\\"(.+?)\\\"\": \"semibold=\\\"\" + fonts[1] + \"\\\"\",\n        \"^semilight=\\\"(.+?)\\\"\": \"semilight=\\\"\" + fonts[2] + \"\\\"\",\n        \"^light=\\\"(.+?)\\\"\": \"light=\\\"\" + fonts[3] + \"\\\"\",\n    }\n\n    for pattern, replacement in matches.items():\n        styles = re.sub(pattern, replacement, styles, 0, re.M)\n\n    return styles\n\n###################\n# color functions #\n###################\ndef getConfigAlpha():\n    # read the config file and return a dictionary of the variables and color variables\n    with open(os.path.join(CONFIG_DIR, CONFIG_FILE)) as f:\n        # save the lines of the config file to rawFile\n        rawFile = f.readlines()\n\n    # loop through rawFile\n    result = []\n    for line in rawFile:\n        tmpResult = line[line.find(\",\")+1:line.find(\"\\n\")]\n        result.append(tmpResult)\n    return result\n\ndef getConfigColor():\n    # read the config file and return a dictionary of the variables and color variables\n    with open(os.path.join(CONFIG_DIR, CONFIG_FILE)) as f:\n        # save the lines of the config file to rawFile\n        rawFile = f.readlines()\n\n    # loop through rawFile\n    result = []\n    for line in rawFile:\n        tmpResult = line[line.find(\"=\")+1:line.find(\",\")]\n        result.append(tmpResult)\n    return result\n\ndef getConfigVar():\n    # read the config file and return a dictionary of the variables and color variables\n    with open(os.path.join(CONFIG_DIR, CONFIG_FILE)) as f:\n        # save the lines of the config file to rawFile\n        rawFile = f.readlines()\n\n    # loop through rawFile\n    result = []\n    for line in rawFile:\n        tmpResult = line[:line.find(\"=\")]\n        result.append(tmpResult)\n    f.close()\n    return result\n\ndef hexToRgb(hexColors):\n    \"\"\"Convert hex colors to rgb colors (takes a list).\"\"\"\n    return [tuple(bytes.fromhex(color.strip(\"#\"))) for color in hexColors]\n\ndef getColors(mode):\n    if (mode == 0):\n        # using colors from wal\n        colorsFile = WAL_COLORS\n    else:\n        # using colors from wpg\n        colorsFile = WPG_COLORS\n    # parse the file\n    print(\"Reading colors\")\n    try:\n        with open(colorsFile) as f:\n            rawFile = f.readlines()  # save the lines to rawFile\n    except:\n        print(\"Error: Colors file missing. Make sure you've run pywal/wpg before wal_steam\")\n        sys.exit(1)\n\n    # delete the lines not involving the colors\n    del rawFile[0:11]\n    del rawFile[16]\n\n    # loop through rawFile and store colors in a list\n    colors = []\n    for line in rawFile:\n        # delete everything but the hex code\n        tmp = line[line.find(\"#\"):]\n        tmp = tmp[:7]\n\n        # append the hex code to the colors list\n        colors.append(tmp)\n\n    return colors\n\n##########################\n# checkInstall functions #\n##########################\n\ndef checkSkin(steam_dir, dpi):\n    # check for skin and patch in cache\n    if not (os.path.isdir(METRO_DIR) and os.path.isdir(METRO_PATCH_COPY)):\n        # metro skin and patch not found in cache, download and make\n        makeSkin()\n    # check for patched skin in steam skin directory\n    if not os.path.isdir(os.path.join(steam_dir, SKIN_NAME)):\n        # patched skin not found in steam, copy it over\n        print(\"Installing skin\")\n        copy_tree(METRO_DIR, os.path.join(steam_dir, SKIN_NAME))\n    else:\n        print(\"Wal Steam skin found\")\n        if (dpi==1):\n            # skin was not found, copy it over\n            print(\"Forcing skin install for High DPI patches\")\n            copy_tree(METRO_DIR, os.path.join(steam_dir, SKIN_NAME))\n\ndef makeSkin():\n    # download metro for steam and extract\n    print(\"Downloading Metro for steam\")\n    try:\n        opener = urllib.request.build_opener()\n        opener.addheaders = [{'User-Agent', 'Mozilla/5.0'}]\n        urllib.request.install_opener(opener)\n        urllib.request.urlretrieve(METRO_URL, METRO_ZIP)\n    except:\n        print(\"Error: downloading needed skin file. Check your connection and try again.\")\n        sys.exit(1)\n\n    with zipfile.ZipFile(METRO_ZIP, 'r') as z:\n        z.extractall(CACHE_DIR)\n\n    # download metro for steam patch and extract\n    print(\"Attempting to download Metro patch\")\n    patch_dl_attempts = 0\n    patch_dld = False\n    while (patch_dl_attempts < MAX_PATCH_DL_ATTEMPTS) and not patch_dld:\n        try:\n            opener = urllib.request.build_opener()\n            urllib.request.install_opener(opener)\n            urllib.request.urlretrieve(METRO_PATCH_URL, METRO_PATCH_ZIP)\n            patch_dld = True\n        except:\n            patch_dl_attempts += 1\n            print(\"Error: download attempt \" + str(patch_dl_attempts) + \" failed.\")\n            if patch_dl_attempts < MAX_PATCH_DL_ATTEMPTS:\n                time.sleep(5)\n\n    if not patch_dld:\n        print(\"Error: patch download attempts failed, exiting...\")\n        sys.exit(1)\n    else:\n        print(\"Patch downloaded, proceeding...\")\n\n    with zipfile.ZipFile(METRO_PATCH_ZIP, 'r') as z:\n        z.extractall(METRO_PATCH_DIR)\n\n    # finally apply the patch\n    copy_tree(METRO_PATCH_COPY, METRO_DIR) # use copy_tree not copytree, shutil copytree is broken\n\ndef makeConfig():\n    # download the config for wal_steam\n    print (\"Downloading config file\")\n    try:\n        urllib.request.urlretrieve(CONFIG_URL, os.path.join(CONFIG_DIR, CONFIG_FILE))\n    except:\n        # problem with download\n        # generate the config instead\n        print(\"Error: downloading needed config file.\")\n        sys.exit(1)\n\ndef makeDpi():\n    # apply the high dpi\n    print (\"Applying the high dpi patches\")\n    copy_tree(METRO_PATCH_HDPI, METRO_DIR)\n\ndef delConfig():\n    # delete the config\n    if os.path.isdir(CONFIG_DIR):\n        shutil.rmtree(CONFIG_DIR)\n\ndef delCache():\n    # delete the cache\n    if os.path.isdir(CACHE_DIR):\n        shutil.rmtree(CACHE_DIR)\n\ndef delSkin(steam_dir):\n    # delete the skin\n    if os.path.isdir(os.path.join(steam_dir, SKIN_NAME)):\n        shutil.rmtree(os.path.join(steam_dir, SKIN_NAME))\n\ndef checkConfig():\n    # check for the config\n    if not os.path.isdir(os.path.join(HOME_DIR, \".config\")):\n        # make the .config folder\n        os.mkdir(os.path.join(HOME_DIR, \".config\"))\n    if not os.path.isdir(CONFIG_DIR):\n        # make the config directory\n        os.mkdir(CONFIG_DIR)\n\n        # download or make config file\n        makeConfig()\n    elif not os.path.isfile(os.path.join(CONFIG_DIR, CONFIG_FILE)):\n        # download or make the config file\n        makeConfig()\n    else:\n        # config file found!\n        print(\"Wal Steam config found\")\n\ndef checkCache(dpi):\n    # check for the cache\n    if not os.path.isdir(os.path.join(HOME_DIR, \".cache\")):\n        # make the .cache folder\n        os.mkdir(os.path.join(HOME_DIR, \".cache\"))\n    if not os.path.isdir(CACHE_DIR):\n        # make the cache directory\n        os.mkdir(CACHE_DIR)\n\n        # download, extract, and patch metro for steam\n        makeSkin()\n\n        # apply the dpi patches\n        if (dpi==1):\n            makeDpi()\n    else:\n        # cache folder exists\n        print(\"Wal Steam cache found\")\n\n        # apply the dpi patches\n        if (dpi==1):\n            makeDpi()\n\ndef checkInstall(oSys, dpi):\n    # check if the cache exists, make it if not\n    checkCache(dpi)\n\n    # check if the config file exists\n    checkConfig()\n\n    # check if the skin is installed, install it if not\n    checkSkin(oSys, dpi)\n\ndef forceUpdate(oSys, dpi):\n    # force update the cache and config files\n    delConfig()\n    delCache()\n    delSkin(oSys)\n    checkCache(dpi)\n    checkConfig()\n\ndef getOs():\n    # check if ~/.steam/steam/skins exists\n    if os.path.isdir(STEAM_DIR_OTHER):\n        return STEAM_DIR_OTHER\n    # check if ~/.steam/skins exists\n    elif os.path.isdir(STEAM_DIR_UBUNTU):\n        return STEAM_DIR_UBUNTU\n    # check if C:\\Program Files (x86)\\Steam\\skins exists\n    elif os.path.isdir(STEAM_DIR_WINDOWS):\n        return STEAM_DIR_WINDOWS\n    elif os.path.isdir(STEAM_DIR_OSX):\n        return STEAM_DIR_OSX\n    # close with error message otherwise\n    else:\n        print(\"Error: Steam install not found!\")\n        sys.exit(1)\n\ndef parseFontArgs(rawArgs):\n    splitArgs = [arg.strip() for arg in rawArgs.split(\",\")]\n\n    if len(splitArgs) != 4:\n        print(\"Error: You must specify all four custom font styles.\")\n        sys.exit(1)\n\n    return splitArgs\n\ndef getArgs():\n    # get the arguments with argparse\n    description = \"Wal Steam\"\n    arg = argparse.ArgumentParser(description=description, formatter_class=RawTextHelpFormatter)\n\n    arg.add_argument(\"-v\", \"--version\", action=\"store_true\",\n        help=\"Print wal_steam version.\")\n\n    arg.add_argument(\"-w\", action=\"store_true\",\n        help=\"Get colors from wal.\")\n\n    arg.add_argument(\"-g\", action=\"store_true\",\n        help=\"Get colors from wpg.\")\n\n    arg.add_argument(\"-s\",\n        help=\"Enter a custom steam skin directory.\")\n\n    arg.add_argument(\"-d\", action=\"store_true\",\n        help=\"Apply high dpi patches.\")\n\n    arg.add_argument(\"-u\", action=\"store_true\",\n        help=f\"Force update cache, skin, and config file. {CLI_RED}WARNING:{CLI_END} WILL OVERWRITE config.json\")\n\n    arg.add_argument(\"-f\", \"--fonts\",\n        help=textwrap.dedent(f'''\n            Specify custom fonts. Enter font styles separated by comma.\n            {CLI_BOLD}Available styles:{CLI_END} basefont, semibold, semilight, light.\n            {CLI_YELLOW}Example:{CLI_END} 'Open Sans, Open Sans Semibold, Open Sans Semilight, Open Sans Light'\n            {CLI_RED}WARNING:{CLI_END} Fonts must already be installed on your system.'''))\n\n    arg.add_argument(\"-a\", \"--attempts\", help=\"Set the number of patch download attempts (DEFAULT=5)\")\n\n    return arg.parse_args()\n\ndef main():\n    # set default mode to wal\n    # 0 = wal\n    # 1 = wpgtk\n    mode = 0\n\n    # parse the arguments\n    arguments = getArgs()\n    if arguments.version:\n        print(\"Wal Steam\", VERSION)\n        sys.exit()\n\n    # make sure they didn't select both wal and wpg\n    if arguments.w and arguments.g:\n        print(\"Error: You must select wpg or wal\")\n        sys.exit(1)\n\n    # set the mode for either wal or wpg\n    if arguments.w:\n        mode = 0\n    if arguments.g:\n        mode = 1\n\n    # check if user wants high-dpi support\n    if arguments.d:\n        dpi = 1\n    if not arguments.d:\n        dpi = 0\n\n    # allow the user to enter a custom steam install location\n    if arguments.s:\n        oSys = arguments.s\n        print(\"Using custom skin path: {}\".format(arguments.s))\n    else:\n        # check where the os installed steam\n        # ~/.steam/steam/skins               - common linux install location\n        # ~/.steam/skins                     - used on ubuntu and its derivatives\n        # C:\\Program Files (x86)\\Steam\\skins - used on windows\n        oSys = getOs()\n\n    # allow the user to enter custom font styles\n    if arguments.fonts:\n        fonts = parseFontArgs(arguments.fonts)\n        print(\"Using custom font styles: {}\".format(arguments.fonts))\n    else:\n        fonts = \"\"\n\n    # update the cache and config then exit\n    if arguments.u:\n        print(\"Force updating cache and config\")\n        # first remove the cache and config\n        forceUpdate(oSys, dpi)\n        print(\"Cache and config updated\")\n        print(\"Run with -w or -g to apply and re-enable wal_steam\")\n        sys.exit()\n\n    if arguments.attempts:\n        try:\n            attempts_bound = int(arguments.attempts)\n            MAX_PATCH_DL_ATTEMPTS = attempts_bound\n        except:\n            print(\"Error setting maximum patch download attempts, using default (5).\")\n\n    # check for the cache, the skin, and get them if needed\n    checkInstall(oSys, dpi)\n\n    # get a list from either wal or wpg based on the mode\n    colors = getColors(mode)\n\n    # convert our list of colors from hex to rgb\n    colors = hexToRgb(colors)\n\n    # get a dictionary of the config settings from the config file\n    variables = getConfigVar()\n    walColors = getConfigColor()\n    alpha = getConfigAlpha()\n\n    # finally create a temp colors.styles and copy it in updating the skin\n    setCustomStyles(colors, variables, walColors, alpha, oSys, fonts)\n\nif __name__ == '__main__':\n    main()\n"
  }
]