├── README.md ├── b00merang_aliases ├── bin ├── dark-mode ├── git-batch ├── git-batch-all ├── git-clone ├── git-clone-artwork ├── git-clone-theme ├── git-commit-all ├── git-pull-all ├── git-push-all ├── git-status-all ├── set-theme └── window-buttons ├── clone-repos.sh ├── env-setup.sh ├── gtkresource ├── gextract └── gtk-compile ├── link-themes.sh ├── root-link-themes.sh └── theme4-manager.sh /README.md: -------------------------------------------------------------------------------- 1 | # Shell scripts 2 | 3 | A collection of shell scripts used to develop and maintain the B00merang themes 4 | -------------------------------------------------------------------------------- /b00merang_aliases: -------------------------------------------------------------------------------- 1 | # Aliases 2 | alias gthemes="cd /usr/share/themes" 3 | alias gicons="cd /usr/share/icons" 4 | alias lthemes="cd $HOME/.themes" 5 | alias licons="cd $HOME/.icons" 6 | alias lbin="cd $HOME/.local/bin" 7 | 8 | alias oad="cd $HOME/Github/Azurra_framework" 9 | alias hub="cd $HOME/Github" 10 | -------------------------------------------------------------------------------- /bin/dark-mode: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | if [[ "$1" == "" ]]; then 4 | echo "Invalid theme (must be in ~/.themes)" 5 | exit 6 | elif [[ "$2" != "on" ]] || [[ "$2" != "off" ]]; then 7 | echo "Invalid action (on/off)" 8 | exit 9 | fi 10 | 11 | cd $HOME/.themes/$1 12 | 13 | if [[ $2 == "on" ]] 14 | then 15 | echo "On" 16 | mv $HOME/.themes/$1/gtk-3.0/gtk.css $HOME/.themes/$1/gtk-3.0/gtk-orig.css 17 | mv $HOME/.themes/$1/gtk-3.0/gtk-dark.css $HOME/.themes/$1/gtk-3.0/gtk.css 18 | 19 | mv $HOME/.themes/$1/gtk-3.20/gtk.css $HOME/.themes/$1/gtk-3.20/gtk-orig.css 20 | mv $HOME/.themes/$1/gtk-3.20/gtk-dark.css $HOME/.themes/$1/gtk-3.20/gtk.css 21 | elif [[ $2 == "off" ]] 22 | then 23 | echo "Off" 24 | mv $HOME/.themes/$1/gtk-3.0/gtk.css $HOME/.themes/$1/gtk-3.0/gtk-dark.css 25 | mv $HOME/.themes/$1/gtk-3.0/gtk-orig.css $HOME/.themes/$1/gtk-3.0/gtk.css 26 | 27 | mv $HOME/.themes/$1/gtk-3.20/gtk.css $HOME/.themes/$1/gtk-3.20/gtk-dark.css 28 | mv $HOME/.themes/$1/gtk-3.20/gtk-orig.css $HOME/.themes/$1/gtk-3.20/gtk.css 29 | fi 30 | -------------------------------------------------------------------------------- /bin/git-batch: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # save user login creds 4 | if [ -d .git ]; then 5 | git config credential.helper store 6 | 7 | # Added to prevent conflicts when updated from other VM 8 | echo "Checking for upstream changes..." 9 | 10 | git fetch 11 | OUT=$(git status -sb) 12 | 13 | if [[ "$OUT" = *"behind"* ]]; then 14 | echo "[WARNING] Upstream changes may conflict with local changes" 15 | else 16 | git add --all 17 | git commit -m "$1" 18 | git push 19 | fi 20 | else 21 | echo "Not a git repository" 22 | fi 23 | -------------------------------------------------------------------------------- /bin/git-batch-all: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | msg="$1" 4 | shift 5 | 6 | for D in *; do 7 | if ls ${D}/*.sh &>/dev/null; then continue; fi 8 | if [ -d "${D}" ] && [ -d "${D}/.git" ]; then 9 | cd "${D}" 10 | OUT=$(git status) 11 | 12 | if [[ "$OUT" != *"nothing to commit"* ]]; then 13 | git config credential.helper store 14 | 15 | # Added to prevent conflicts when updated from other VM 16 | echo "Checking for upstream changes..." 17 | 18 | git fetch 19 | OUT=$(git status -sb) 20 | 21 | if [[ "$OUT" = *"behind"* ]]; then 22 | echo "[WARNING] Upstream changes may conflict with local changes" 23 | else 24 | git add --all 25 | git commit -m "$msg" 26 | git push 27 | 28 | tput setaf 4 29 | 30 | echo "" 31 | echo "Pushing from local '${D}' to origin" 32 | echo "" 33 | 34 | tput op 35 | fi 36 | fi 37 | 38 | cd .. 39 | fi 40 | done 41 | -------------------------------------------------------------------------------- /bin/git-clone: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | git clone "https://github.com/$1" 4 | -------------------------------------------------------------------------------- /bin/git-clone-artwork: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | git clone "https://github.com/B00merang-Artwork/$1" 4 | -------------------------------------------------------------------------------- /bin/git-clone-theme: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | git clone "https://github.com/B00merang-Project/$1" 4 | -------------------------------------------------------------------------------- /bin/git-commit-all: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | msg="$1" 4 | shift 5 | 6 | for D in *; do 7 | if ls ${D}/*.sh &>/dev/null; then continue; fi 8 | if [ -d "${D}" ] && [ -d "${D}/.git" ]; then 9 | cd "${D}" 10 | OUT=$(git status) 11 | 12 | if [[ "$OUT" != *"nothing to commit"* ]]; then 13 | git config credential.helper store 14 | 15 | git add --all 16 | git commit -m "$msg" 17 | 18 | tput setaf 4 19 | 20 | echo "" 21 | echo "Pushing from local '${D}' to origin" 22 | echo "" 23 | 24 | tput op 25 | fi 26 | 27 | cd .. 28 | fi 29 | done 30 | -------------------------------------------------------------------------------- /bin/git-pull-all: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | for D in *; do 4 | if [ ! -f "${D}/.bsi" ]; then 5 | if [ -d "${D}" ] && [ -d "${D}/.git" ]; then 6 | tput setaf 4 7 | echo "Fetching from '${D}' repository" 8 | tput op 9 | 10 | cd "${D}" 11 | git pull 12 | 13 | cd .. 14 | 15 | echo "--------------------" 16 | fi 17 | fi 18 | done 19 | -------------------------------------------------------------------------------- /bin/git-push-all: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | msg="$1" 4 | shift 5 | 6 | for D in *; do 7 | if ls ${D}/*.sh &>/dev/null; then continue; fi 8 | if [ -d "${D}" ] && [ -d "${D}/.git" ]; then 9 | cd "${D}" 10 | OUT=$(git status) 11 | 12 | git push 13 | 14 | cd .. 15 | fi 16 | done 17 | -------------------------------------------------------------------------------- /bin/git-status-all: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | for D in *; do 4 | if ls ${D}/*.sh &>/dev/null; then continue; fi 5 | if [ -d "${D}" ] && [ -d "${D}/.git" ]; then 6 | tput setaf 4 7 | echo -n "Checking status of '${D}' repository: " 8 | 9 | cd "${D}" 10 | OUT=$(git status) 11 | 12 | if [[ "$OUT" = *"nothing to commit"* ]]; then 13 | tput setaf 2 14 | echo "Up to date" 15 | else 16 | if [ "$1" == "-d" ]; then 17 | tput op 18 | echo "$OUT" 19 | else 20 | tput setaf 1 21 | echo "Needs updating" 22 | fi 23 | fi 24 | 25 | tput op 26 | 27 | cd .. 28 | fi 29 | done 30 | -------------------------------------------------------------------------------- /bin/set-theme: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | if [ ! -z "$1" ] 4 | then 5 | gsettings set org.gnome.desktop.interface gtk-theme "$1" 6 | else 7 | echo "Missing argument: theme name" 8 | fi 9 | -------------------------------------------------------------------------------- /bin/window-buttons: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | for arg in $@; do 4 | case $arg in 5 | -h|--help|help) 6 | echo ' cde|macos|macos9|win|gnome|openlook' 7 | ;; 8 | cde|beos) 9 | gsettings set org.gnome.desktop.wm.preferences button-layout 'close:,minimize,maximize' 10 | ;; 11 | macos) 12 | gsettings set org.gnome.desktop.wm.preferences button-layout 'close,minimize,maximize:' 13 | ;; 14 | macos9) 15 | gsettings set org.gnome.desktop.wm.preferences button-layout 'close:,maximize,minimize' 16 | ;; 17 | win) 18 | gsettings set org.gnome.desktop.wm.preferences button-layout ':minimize,maximize,close' 19 | ;; 20 | gnome) 21 | gsettings set org.gnome.desktop.wm.preferences button-layout ':close' 22 | ;; 23 | openlook) 24 | gsettings set org.gnome.desktop.wm.preferences button-layout 'close:' 25 | ;; 26 | esac 27 | done 28 | -------------------------------------------------------------------------------- /clone-repos.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | read -p "Repos will be cloned here. Continue? " -n 1 -r 4 | echo # (optional) move to a new line 5 | if [[ $REPLY =~ ^[Yy]$ ]] 6 | then 7 | wget https://gist.githubusercontent.com/Elbullazul/3c5e746f224d8abde5b0e6a6d4809200/raw/f4098fa755038379d7095d4bb631e29a9e5a72af/themes.index 8 | 9 | while IFS= read -r url || [ -n "$url" ]; do 10 | git clone "$url" 11 | done < themes.index 12 | 13 | rm themes.index 14 | else 15 | echo "Aborted." 16 | fi 17 | 18 | -------------------------------------------------------------------------------- /env-setup.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | echo -n "Linking aliases file ($HOME/.b00merang_aliases)... " 4 | if [ ! -f $HOME/.b00merang_aliases ] 5 | then 6 | ln -s $PWD/b00merang_aliases $HOME/.b00merang_aliases 7 | fi 8 | echo "Done" 9 | 10 | if [ ! -f $HOME/.bashrc ] 11 | then 12 | echo "source $HOME/.b00merang_aliases" >>$HOME/.bashrc 13 | fi 14 | 15 | if [ ! -f $HOME.zshrc ] 16 | then 17 | echo "source $HOME/.b00merang_aliases" >>$HOME/.zshrc 18 | fi 19 | 20 | echo "Linking commands ($HOME/.local/bin)... " 21 | if [ ! -d $HOME/.local ] 22 | then 23 | mkdir $HOME/.local 24 | elif [ ! -d $HOME/.local/bin ] 25 | then 26 | mkdir $HOME/.local/bin 27 | fi 28 | 29 | for file in bin/* 30 | do 31 | echo "Linking $file" 32 | ln -s "$PWD/$file" $HOME/.local/bin/ 33 | done 34 | echo "Done" 35 | 36 | read -p "Install packages? (y/n/): " yesno 37 | 38 | if [ $yesno == "y" ] 39 | then 40 | if [ -f /bin/pacman ] 41 | then 42 | sudo pacman -Sy sassc gtk3-demos gtk4-demos imagemagick 43 | elif [ -f /bin/apt ] 44 | then 45 | sudo apt install -y sassc gtk-3-examples imagemagick 46 | elif [ -f /bin/dnf ] 47 | then 48 | sudo dnf install -y sassc gtk3-devel gtk4-devel gtk4-devel-tools ImageMagick 49 | fi 50 | fi 51 | 52 | echo "Done." 53 | -------------------------------------------------------------------------------- /gtkresource/gextract: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | ############################################################################## 3 | # Author: Peter Gordon 4 | # License: Public Domain 5 | ############################################################################## 6 | # gresource-extract.sh 7 | # Version: 1 8 | # 9 | # This Bash script is designed to extract all resource files in a given 10 | # GResource file, with the given base folder. For example, if a GResource file 11 | # contained the resource /org/foo/bar/baz.txt, and the base folder is given 12 | # as "/org/foo/", then the resource named /org/foo/bar/baz.txt in that file 13 | # would be extracted and written to bar/baz.txt in the current directory. 14 | ############################################################################## 15 | # __ ChangeLog __ 16 | # 2012-07-22 17 | # * Version 1 18 | # - Initial public release 19 | ############################################################################## 20 | 21 | # The GResource file name 22 | GR_FILE="gtk.gresource" 23 | 24 | # The base folder of the extracted resources 25 | GR_BASEDIR="/org/gnome/" 26 | 27 | 28 | ## Check for required utilities... 29 | for REQUIRED_PROG in gresource 30 | do 31 | which ${REQUIRED_PROG} &>/dev/null 32 | if [ $? -ne 0 ]; then 33 | echo "Unable to find required program '${REQUIRED_PROG}' in PATH." 34 | exit 1 35 | fi 36 | done 37 | 38 | 39 | for RSRC in $(gresource list $GR_FILE) 40 | do 41 | RSRC_FILE=$(echo "${RSRC#$GR_BASEDIR}") 42 | mkdir -p $(dirname "$RSRC_FILE") ||: 43 | gresource extract "$GR_FILE" "$RSRC" > "$RSRC_FILE" 44 | done 45 | 46 | -------------------------------------------------------------------------------- /gtkresource/gtk-compile: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # based on http://wibblystuff.blogspot.ca/2012/06/building-binary-for-gtk3-theme.html 4 | 5 | echo 'To use this script you must have the follwowing packages installed: 6 | libgtk-3-dev 7 | libglib2.0-dev 8 | libgdk-pixbuf2.0-dev 9 | libxml2-utils 10 | 11 | run sudo apt install -y libgtk-3-dev libglib2.0-dev libgdk-pixbuf2.0-dev libxml2-utils to install them now' 12 | 13 | read -p "Enter path to theme gtk-3.0 folder: " "path" 14 | 15 | cd "$path" 16 | 17 | read -p "Enter theme name: " "theme" 18 | 19 | mkdir "$PWD.bak" 20 | cp * -r "$PWD.bak" # backup copy 21 | 22 | cp gtk.css gtk-main.css 23 | 24 | if [ -a gtk-dark.css ]; then 25 | cp gtk-dark.css gtk-dark-main.css 26 | fi 27 | 28 | file="$PWD/gtk.gresource.xml" 29 | header='\n\n' 31 | 32 | echo -e "$header$theme$post" >> "$file" 33 | 34 | # for D in *; do find "$D" -type d; done #list all firs, type f for files 35 | 36 | sub_append() { 37 | 38 | for F in *; do 39 | if [[ $F == *.css ]]; then 40 | echo "$1/$F" >> "$file" 41 | elif [[ $F == *.png ]]; then 42 | echo "$1/$F" >> "$file" 43 | fi 44 | done 45 | 46 | } 47 | append() { 48 | for F in *; do 49 | if [[ $F == *.css ]]; then 50 | echo "$F" >> "$file" 51 | elif [[ $F == *.png ]]; then 52 | echo "$F" >> "$file" 53 | fi 54 | done 55 | } 56 | 57 | for D in *; do 58 | if [ -d "${D}" ]; then 59 | cd "${D}" 60 | echo "${D}" 61 | sub_append "${D}" 62 | cd .. 63 | fi 64 | done 65 | 66 | # current directory 67 | append 68 | 69 | echo -e "\n" >> "$file" 70 | 71 | glib-compile-resources gtk.gresource.xml 72 | 73 | printf '@import url("resource:///org/gnome/' >> gtk.css 74 | printf "$theme" >> gtk.css 75 | printf '/gtk-main.css");' >> gtk.css 76 | 77 | if [ -a gtk-dark.css ]; then 78 | printf '@import url("resource:///org/gnome/' >> gtk-dark.css 79 | printf "$theme" >> gtk-dark.css 80 | printf '/gtk-dark-main.css");' >> gtk-dark.css 81 | fi 82 | 83 | -------------------------------------------------------------------------------- /link-themes.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | if [ ! -d $HOME/.themes ]; then 4 | mkdir $HOME/.themes 5 | fi 6 | 7 | echo "Linking repositories in $HOME/.themes" 8 | 9 | for D in *; do 10 | if [ -d "${D}" ]; then 11 | if [ -d "${D}/gtk-3.0" ]; then 12 | echo "Linking ${D}" 13 | ln -s "$PWD/${D}" "$HOME/.themes" 14 | else 15 | cd "${D}" 16 | for SD in *; do 17 | if [ -d "${SD}" ] && [ -d "${SD}/gtk-3.0" ]; then 18 | echo "Linking ${SD}" 19 | ln -s "$PWD/${SD}" "$HOME/.themes" 20 | fi 21 | done 22 | cd .. 23 | fi 24 | fi 25 | done 26 | -------------------------------------------------------------------------------- /root-link-themes.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | echo "Linking repositories in /usr/share/themes" 4 | 5 | for D in *; do 6 | if [ -d "${D}" ]; then 7 | if [ -d "${D}/gtk-3.0" ]; then 8 | echo "Linking ${D}" 9 | ln -s "$PWD/${D}" "/usr/share/themes" 10 | else 11 | cd "${D}" 12 | for SD in *; do 13 | if [ -d "${SD}" ] && [ -d "${SD}/gtk-3.0" ]; then 14 | echo "Linking ${SD}" 15 | ln -s "$PWD/${SD}" "/usr/share/themes" 16 | fi 17 | done 18 | cd .. 19 | fi 20 | fi 21 | done 22 | -------------------------------------------------------------------------------- /theme4-manager.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # declare variables 4 | declare -a GTK4_CONFIG 5 | declare -a USER_THEMES 6 | declare -a SHARED_THEMES 7 | 8 | GTK4_CONFIG="$HOME/.config/gtk-4.0" 9 | 10 | # uninstall theme if received argument 11 | [ "$1" == '-u' ] || [ "$1" == "--uninstall" ] && [ ! -z $GTK4_CONFIG ] && rm -rf $GTK4_CONFIG/* && echo "Uninstalled GTK4 theme" && exit 12 | 13 | # show help 14 | [ "$1" == '-h' ] || [ "$1" == '--help' ] && echo "Available options: [ -h | --help ] [ -u | --uninstall ]" && exit 15 | 16 | # greet the user! 17 | echo " _ ___ ___ 18 | | |__ / _ \ / _ \ _ __ ___ ___ _ __ __ _ _ __ __ _ 19 | | '_ \ | | | | | | | | | '_ \` _ \ / _ \ | '__| / _\` | | '_ \ / _\` | 20 | | |_) | | |_| | | |_| | | | | | | | | __/ | | | (_| | | | | | | (_| | 21 | |_.__/ \___/ \___/ |_| |_| |_| \___| |_| \__,_| |_| |_| \__, | 22 | |___/ " 23 | 24 | echo "Welcome to b00merang's GTK 4 theme installer" 25 | read -n 1 -s -r -p "Press any key to continue..." 26 | 27 | # check if gtk-4.0 folder present, create it if not 28 | [ ! -d "$GTK4_CONFIG" ] && mkdir "$GTK4_CONFIG" 29 | 30 | # TODO: override with `/usr/share/themes` if flag received 31 | theme_folder="$HOME/.themes" 32 | 33 | # find theme folders found in ~/.themes with a `gtk-4.0` folder and `gtk-4.0/gtk.css` file 34 | if [ -d $theme_folder ]; then 35 | for theme in "$theme_folder/"*; do 36 | [ ! -d "$theme/gtk-4.0" ] && continue 37 | [ ! -f "$theme/gtk-4.0/gtk.css" ] && continue 38 | 39 | # store paths in array 40 | USER_THEMES+=("$theme") 41 | done 42 | else 43 | echo "$theme_folder does not exist, try again" 44 | exit 45 | fi 46 | 47 | # erase press to continue line 48 | printf "\rList of available themes:" 49 | echo 50 | 51 | # show themes in 2 columns with a number 52 | pr -2T <<< $(for (( t=1; t<=${#USER_THEMES[@]}; t++ )); do 53 | echo " $t `basename "${USER_THEMES[$(($t - 1))]}"`" 54 | done) 55 | 56 | input="" 57 | theme_count=${#USER_THEMES[@]} 58 | 59 | # ask for user choice and check if answer is valid 60 | while true; do 61 | read -p "Enter number of theme to install (1-$theme_count) " input 62 | if [ $input -gt 0 ] && [ $input -le $theme_count ]; then 63 | break; 64 | fi 65 | 66 | # if answer not correct, keep asking until it is, or user closes script 67 | echo "Invalid number: $input" 68 | done 69 | 70 | selected_theme=${USER_THEMES[$input - 1]} 71 | 72 | # if another theme is already present in ~/gtk-4.0, ask for confirmation 73 | if [ -f "$GTK4_CONFIG/gtk.css" ]; then 74 | read -p "A theme is already installed, do you want to overwrite it? (y/N) " yesno 75 | 76 | [[ ! $yesno =~ ^[Yy]$ ]] && echo "Operation was cancelled" && exit 77 | fi 78 | 79 | # copy everything in $selected_theme/gtk-4.0 to ~/.config/gtk-4.0 80 | cp -R "$selected_theme/gtk-4.0/"* "$GTK4_CONFIG" 81 | 82 | echo "Copied theme '`basename "$selected_theme"`'" 83 | --------------------------------------------------------------------------------