Last active
July 27, 2020 21:06
-
-
Save jurf/9b520d94a6ce9d21870848242883400d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# night-theme-switch | |
# ------------------ | |
# Written as a complement to the Night Theme Switcher GNOME Shell extension: | |
# https://gitlab.com/rmnvgr/nightthemeswitcher-gnome-shell-extension/ | |
# | |
# Works best with Solarized. | |
# Copyright (c) 2020 Juraj Fiala | |
# | |
# Permission is hereby granted, free of charge, to any person obtaining a copy | |
# of this software and associated documentation files (the "Software"), to deal | |
# in the Software without restriction, including without limitation the rights | |
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
# copies of the Software, and to permit persons to whom the Software is | |
# furnished to do so, subject to the following conditions: | |
# | |
# The above copyright notice and this permission notice shall be included in all | |
# copies or substantial portions of the Software. | |
# | |
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | |
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | |
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | |
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | |
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | |
# SOFTWARE. | |
readonly TERM_PROFILE_PATH='/org/gnome/terminal/legacy/profiles:/' | |
readonly TERM_PROFILE_ID='b1dcc9dd-5262-4d8d-a863-c897e6d979b9' | |
readonly VSCODE_CONFIG="$HOME/.var/app/com.visualstudio.code/config/Code/User/settings.json" | |
function print-help() { | |
echo "Usage: $0 [--help | --night | --day]" | |
} | |
function terminal-set() { | |
dconf write "$TERM_PROFILE_PATH:$TERM_PROFILE_ID/background-color" "'$1'" | |
dconf write "$TERM_PROFILE_PATH:$TERM_PROFILE_ID/foreground-color" "'$2'" | |
} | |
function terminal-light() { | |
terminal-set 'rgb(253,246,227)' 'rgb(101,123,131)' | |
} | |
function terminal-dark() { | |
terminal-set 'rgb(0,43,54)' 'rgb(131,148,150)' | |
} | |
function fish-light() { | |
fish -c " | |
set -U fish_color_command 586e75; | |
set -U fish_color_quote 839496; | |
set -U fish_color_param 657b83; | |
set -U fish_color_search_match bryellow --background=white; | |
set -U fish_color_autosuggestion 93a1a1; | |
set -U fish_pager_color_completion green; | |
set -U fish_color_comment 93a1a1; | |
" | |
} | |
function fish-dark() { | |
fish -c " | |
set -U fish_color_command 93a1a1; | |
set -U fish_color_quote 657b83; | |
set -U fish_color_param 839496; | |
set -U fish_color_search_match bryellow --background=black; | |
set -U fish_color_autosuggestion 586e75; | |
set -U fish_pager_color_completion B3A06D; | |
set -U fish_color_comment 586e75; | |
" | |
} | |
function vscode-set() { | |
sed -i "/workbench\.colorTheme/ $1" "$VSCODE_CONFIG" | |
} | |
function vscode-dark() { | |
vscode-set 's/Light/Dark/' | |
} | |
function vscode-light() { | |
vscode-set 's/Dark/Light/' | |
} | |
function main() { | |
case $1 in | |
'--day' | '--light' ) | |
terminal-light | |
fish-light | |
vscode-light | |
;; | |
'--night' | '--dark' ) | |
terminal-dark | |
fish-dark | |
vscode-dark | |
;; | |
'--help' | '-h' ) | |
print-help | |
;; | |
'') | |
echo "Missing option after '$0'" | |
print-help | |
exit 1 | |
;; | |
*) | |
echo "'$1': Invalid option" | |
print-help | |
exit 1 | |
;; | |
esac | |
} | |
main "$@" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment