Skip to content

Commit

Permalink
Add support for PROGRAMFILES installations
Browse files Browse the repository at this point in the history
Hello! Love this script. This didn't work when running with an enterprise-installed slack client (because slack was installed into Program Files).

There's probably a more elegant way to handle this logic, but this is what I was able to get working.

Thanks again! I know this is a bit of a corner-case
  • Loading branch information
znd4 authored Jun 20, 2019
1 parent b475b48 commit 1449dab
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions makeitdark.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,21 @@
slack_theme_path = "/Applications/Slack.app/Contents/Resources/app.asar.unpacked/src/static/ssb-interop.js"
else:
# Probably Windows
slack_root_path = os.path.join(os.environ['LOCALAPPDATA'], "slack")
most_recent = sorted([slack_version for slack_version in os.listdir(slack_root_path) if slack_version.startswith("app-") and os.path.isdir(os.path.join(slack_root_path, slack_version))], reverse=True)[0]
print("Searching for most recent slack update in {0}".format(slack_root_path))
print("Found {0}".format(most_recent))
slack_theme_path = os.path.join(slack_root_path, most_recent, "resources", "app.asar.unpacked", "src", "static", "ssb-interop.js")
for root in os.environ['LOCALAPPDATA'], os.environ['PROGRAMFILES']:
slack_root_path = os.path.join(root, "slack")
slack_versions = sorted([slack_version for slack_version in os.listdir(slack_root_path) if slack_version.startswith("app-") and os.path.isdir(os.path.join(slack_root_path, slack_version))], reverse=True)
if not slack_versions:
continue

most_recent = slack_versions[0]
print("Searching for most recent slack update in {0}".format(slack_root_path))
print("Found {0}".format(most_recent))
slack_theme_path = os.path.join(slack_root_path, most_recent, "resources", "app.asar.unpacked", "src", "static", "ssb-interop.js")
if not os.path.exists(slack_theme_path):
continue
break
else:
raise EnvironmentError("Could not find slack installation")

if undo_mode:
with open(slack_theme_path, "r+") as f:
Expand Down

0 comments on commit 1449dab

Please sign in to comment.