Skip to content
This repository has been archived by the owner on Mar 25, 2023. It is now read-only.

Commit

Permalink
Light mode (#152)
Browse files Browse the repository at this point in the history
* windows light mode FIX #111

* don't use alias in windows script

* Mac/Linux Light theme revert. FIX #111

* Force removal of css for light mode #111

* Actually make lightmode/dark mode work for bash

* bash parameter options. #111

* dont exit the script prematurely :)

* update travis for light mode code coverage

* kcovpls

* kcov is mean

* forgot to change the folder for kcov

* more travis update so kcov is happy

* make travis more sane
  • Loading branch information
krazyito65 authored and LanikSJ committed Aug 15, 2019
1 parent c43a303 commit f9292b5
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 6 deletions.
4 changes: 4 additions & 0 deletions .travis.yml
Expand Up @@ -36,9 +36,13 @@ install:
- tar xzf master.tar.gz && cd kcov-master && mkdir build && cd build
- cmake -DCMAKE_INSTALL_PREFIX=${HOME}/kcov .. && make && sudo make install
- cd ../.. && rm -rf kcov-master && mkdir -p coverage
- mkdir -p coverage-light

script:
- sudo kcov coverage slack-dark-mode.sh
- sudo kcov coverage-light slack-dark-mode.sh --light
- sudo kcov coverage-update slack-dark-mode.sh -u

after_success:
- sudo kcov coverage-not-option slack-dark-mode.sh -not-an-option
- bash <(curl -s https://codecov.io/bash)
14 changes: 11 additions & 3 deletions slack-dark-mode.ps1
Expand Up @@ -3,7 +3,8 @@
Param(
[string] $CSSUrl = "https://raw.githubusercontent.com/LanikSJ/slack-dark-mode/master/dark-theme.css",
[string] $SlackBase = $null,
[switch] $UpdateOnly
[switch] $UpdateOnly,
[switch] $LightMode
)

if (-not (Get-Command -Name "npx" -ErrorAction SilentlyContinue)) {
Expand Down Expand Up @@ -34,6 +35,13 @@ if ([string]::IsNullOrWhiteSpace($SlackBase)) {
$resources = Join-Path -Path $latestPath -ChildPath "resources"
$themeFile = Join-Path -Path $resources -ChildPath "custom_theme.css"

if ($LightMode -eq $true) {
Write-Output "Removing Dark Theme.."
Write-Output "Please refresh Slack (ctrl + R)"
Remove-Item $themeFile -Force
exit
}

Write-Output "Stopping Slack"
Get-Process *slack* | Stop-Process -Force

Expand All @@ -43,10 +51,10 @@ if (-not (Test-Path -Path $themeFile)) {
}

Write-Output "Fetching Theme from $CSSUrl"
cat ./dark-theme.css | Set-Content -Path $themeFile # add the theme from the repo
Get-Content ./dark-theme.css | Set-Content -Path $themeFile # add the theme from the repo

if (Test-Path ./custom-dark-theme.css) {
cat ./custom-dark-theme.css | Add-Content $themeFile
Get-Content ./custom-dark-theme.css | Add-Content $themeFile
}

if (-not $UpdateOnly) {
Expand Down
16 changes: 16 additions & 0 deletions slack-dark-mode.sh
Expand Up @@ -9,6 +9,15 @@ OSX_SLACK_RESOURCES_DIR="/Applications/Slack.app/Contents/Resources"
LINUX_SLACK_RESOURCES_DIR="/usr/lib/slack/resources"
UPDATE_ONLY="false"

for arg in "$@"; do
shift
case "$arg" in
-[uU]|--[uU]pdate) UPDATE_ONLY="true" ;;
-[lL]|--[lL]ight) LIGHT_MODE="true" ;;
*) echo "Option doesn't exist"; exit 1 ;;
esac
done

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

type npx
Expand Down Expand Up @@ -36,6 +45,13 @@ fi

if [[ -z $HOME ]]; then HOME=$(ls -d ~); fi

if [[ "$LIGHT_MODE" == "true" ]]; then
echo "Removing Dark Theme.."
echo "Please refresh slack (ctrl/cmd + R)"
sudo rm -f $THEME_FILEPATH
exit
fi

# Copy CSS to Slack Folder
sudo cp -af dark-theme.css "$THEME_FILEPATH"

Expand Down
6 changes: 3 additions & 3 deletions snap-slack-dark-mode.sh
Expand Up @@ -18,8 +18,8 @@ unmount_slack () {
for arg in "$@"; do
shift
case "$arg" in
-u) UPDATE_ONLY="true" ;;
-light)
-[uU]|--[uU]pdate) UPDATE_ONLY="true" ;;
-[lL]|--[lL]ight)
echo "Removing Dark mode"
unmount_slack
exit
Expand Down Expand Up @@ -57,7 +57,7 @@ fi
if [[ "$UPDATE_ONLY" == "false" ]]; then
# ensure we don't have the mount already
unmount_slack

# Unpack Asar Archive for Slack
sudo npx asar extract $SLACK_RESOURCES_DIR/app.asar $ssb_js_dir/app.asar.unpacked

Expand Down

0 comments on commit f9292b5

Please sign in to comment.