Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Windows 10 version not working #4

Open
MPickett1 opened this issue Jul 18, 2019 · 4 comments
Open

Windows 10 version not working #4

MPickett1 opened this issue Jul 18, 2019 · 4 comments

Comments

@MPickett1
Copy link

I have Ubuntu 18.04LTS downloaded as a WSL as suggested in the read me.

I followed the commands, and added a few echo statements to see where it was going wrong, here is the result:

WIN_HOME_RAW=C:\Users\Mike P
USERPROFILE_DRIVE=C:
USERPROFILE_MNT=/mnt/c
WIN_HOME=\Users\Mike P
ls: cannot access '/mnt/c/Users/Mike': No such file or directory
ls: cannot access 'P/AppData/Local/slack/app*/': No such file or directory
Bringing Slack into the darkness...

This script requires sudo privileges.
You'll need to provide your password.
sudo: npx: command not found
tee: '/mnt/c/Users/Mike P/AppData/Local/slack//resources/app.asar.unpacked/dist/ssb-interop.bundle.js': No such file or directory
sudo: npx: command not found

Slack Updated! Refresh or reload slack to see changes

Most of the issues stem from my Users account having a space in them. I fight that constantly and good ole Microsoft forced me into it.

If I run it with sudo, I get the following:

WIN_HOME_RAW=
USERPROFILE_DRIVE=:
USERPROFILE_MNT=
WIN_HOME=
ls: cannot access '/AppData/Local/slack/app*/': No such file or directory
npm is not installed. Please install before continuing.

My npm version is 3.5.2
My nodejs version is v8.10.0

What am I doing wrong?

@MPickett1
Copy link
Author

I got it to work by using quotes around variables where needed. Code below:


#! /usr/bin/env bash

REVERT=false

while test $# -gt 0; do
  case "$1" in
    --revert)
      REVERT=true
      shift
      ;;
    *)
      break
      ;;
  esac
done

JS_START="// First make sure the wrapper app is loaded"

JS="
${JS_START}
document.addEventListener('DOMContentLoaded', function() {
  // Fetch our CSS in parallel ahead of time
  const cssPath = 'https://raw.githubusercontent.com/caiceA/slack-raw/master/slack-4';
  let cssPromise = fetch(cssPath).then((response) => response.text());

  // Insert a style tag into the wrapper view
  cssPromise.then((css) => {
    let s = document.createElement('style');
    s.type = 'text/css';
    s.innerHTML = css;
    document.head.appendChild(s);
  });
});"

OSX_SLACK_RESOURCES_DIR="/Applications/Slack.app/Contents/Resources"
LINUX_SLACK_RESOURCES_DIR="/usr/lib/slack/resources"

if [[ -d $OSX_SLACK_RESOURCES_DIR ]]; then SLACK_RESOURCES_DIR=$OSX_SLACK_RESOURCES_DIR; fi
if [[ -d $LINUX_SLACK_RESOURCES_DIR ]]; then SLACK_RESOURCES_DIR=$LINUX_SLACK_RESOURCES_DIR; fi
if [[ -z $SLACK_RESOURCES_DIR ]]; then
  # Assume on windows if the linux and osx paths failed.
  # Get Windows environment info:
  WIN_HOME_RAW="$(cmd.exe /c "<nul set /p=%UserProfile%" 2>/dev/null)"
  USERPROFILE_DRIVE="${WIN_HOME_RAW%%:*}:"
  USERPROFILE_MNT="$(findmnt --noheadings --first-only --output TARGET "$USERPROFILE_DRIVE")"
  USERPROFILE_DIR="${WIN_HOME_RAW#*:}"
  WIN_HOME="${USERPROFILE_MNT}${USERPROFILE_DIR//\\//}"

  # Find latest version installed
  APP_VER=$(ls -dt "${WIN_HOME}"/AppData/Local/slack/app*/)
  IFS='/', read -a APP_VER_ARR <<< "$APP_VER"

  SLACK_RESOURCES_DIR="${WIN_HOME}"/AppData/Local/slack/"${APP_VER_ARR[8]}"/resources
fi

SLACK_FILE_PATH="${SLACK_RESOURCES_DIR}"/app.asar.unpacked/dist/ssb-interop.bundle.js

# Check if commands exist
if ! command -v node >/dev/null 2>&1; then
  echo "Node.js is not installed. Please install before continuing."
  echo "Node.js is available from: https://nodejs.org/en/download/"
  exit 1
fi
if ! command -v npx >/dev/null 2>&1; then
  echo "npm is not installed. Please install before continuing."
  exit 1
fi

if [ "$REVERT" = true ]; then
echo "Bringing Slack into the light... "
else
echo "Bringing Slack into the darknesss... "
fi

echo ""
echo "This script requires sudo privileges." && echo "You'll need to provide your password."

sudo npx asar extract "${SLACK_RESOURCES_DIR}"/app.asar "${SLACK_RESOURCES_DIR}"/app.asar.unpacked

if [ "$REVERT" = true ]; then
  sudo sed -i.backup '1,/\/\/# sourceMappingURL=ssb-interop.bundle.js.map/!d' "${SLACK_FILE_PATH}"
else
  sudo tee -a "${SLACK_FILE_PATH}" > /dev/null <<< "$JS"
fi

sudo npx asar pack "${SLACK_RESOURCES_DIR}"/app.asar.unpacked "${SLACK_RESOURCES_DIR}"/app.asar

echo ""
echo "Slack Updated! Refresh or reload slack to see changes"

@smitt04
Copy link
Owner

smitt04 commented Jul 18, 2019

Thanks @MPickett1 updated script to be scripted like suggested

@Snowflake6
Copy link

Not sure this is completely fixed. I just tried this and i'm getting a similar error returned when I try to run it under WSL (Ubuntu 18.04):

user@LAPTOP:~$ ./darkSlack.sh
ls: cannot access '/Users/First.Last/AppData/Local/slack/app*/': No such file or directory
Bringing Slack into the darknesss...

This script requires sudo privileges.
You'll need to provide your password.
tee: /Users/First.Last/AppData/Local/slack//resources/app.asar.unpacked/dist/ssb-interop.bundle.js: No such file or directory

Slack Updated! Refresh or reload slack to see changes
user@LAPTOP:~$

I'll add that there is no ssb-interop.bundle.js in the install tree for Slack 4.0.0 on Win 10 either. So unless this script is supposed to create it, I don't know how it gets there?

@smitt04
Copy link
Owner

smitt04 commented Jul 19, 2019

The files get unpacked from the asar file using npx asar package. It still seems like there is a problem discovering some users home directory and slack install location. I am not that versed in wsl for windows. Need someone else to step in

@smitt04 smitt04 reopened this Jul 19, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants