diff --git a/.gitignore b/.gitignore index 53689c9..f0c7ae4 100644 --- a/.gitignore +++ b/.gitignore @@ -1,15 +1 @@ -config/mpv/watch_later/ -fish/config/fishd.* -fish/config/conf.d/ -fish/config/fish_variables -fish/config/conf.d/virtualfish-loader.fish -ranger/config/bookmarks -ranger/config/history -ranger/config/tagged -ranger/config/plugins -Thunar/config/accels.scm -nvim/config/autoload -nvim/config/plugged -nvim/config/.* repos/ -repo/ diff --git a/apps/install.sh b/apps/install.sh deleted file mode 100755 index db0880e..0000000 --- a/apps/install.sh +++ /dev/null @@ -1,31 +0,0 @@ -#!/bin/sh - -DIR=$(dirname "$(readlink -f "$0")") -. "$DIR/../env.sh" - - -# install office utilities -case "$PM" in - apt) - sudo apt install -y \ - google-chrome-stable \ - zathura zathura-pdf-poppler sxiv \ - flameshot \ - gimp - # libreoffice - sudo add-apt-repository -y ppa:libreoffice/libreoffice-7-0 - sudo apt-get update - libreoffice \ - ;; - pacman) - sudo pacman -S --needed \ - chromium \ - zathura zathura-pdf-mupdf sxiv\ - flameshot \ - libreoffice-fresh \ - gimp - ;; -esac - -# symlink configuration -lnsf "$DIR/config/zathura/zathurarc" "$XDG_CONFIG_HOME/zathura/zathurarc" diff --git a/apps/keepassxc.sh b/apps/keepassxc.sh deleted file mode 100755 index e0ef45e..0000000 --- a/apps/keepassxc.sh +++ /dev/null @@ -1,18 +0,0 @@ -#!/bin/sh - -DIR=$(dirname "$(readlink -f "$0")") -. "$DIR/../env.sh" - - -# install nextcloud -case "$PM" in - apt) - sudo add-apt-repository -y ppa:phoerious/keepassxc - sudo apt-get update - sudo apt install -y keepassxc - ;; - pacman) - sudo pacman -S --needed keepassxc - ;; -esac - diff --git a/apps/nextcloud.sh b/apps/nextcloud.sh deleted file mode 100755 index 3046882..0000000 --- a/apps/nextcloud.sh +++ /dev/null @@ -1,17 +0,0 @@ -#!/bin/sh - -DIR=$(dirname "$(readlink -f "$0")") -. "$DIR/../env.sh" - - -# install nextcloud -case "$PM" in - apt) - sudo add-apt-repository -y ppa:nextcloud-devs/client - sudo apt-get update - sudo apt install -y nextcloud-client - ;; - pacman) - sudo pacman -S --needed nextcloud-client - ;; -esac diff --git a/autologin/install.sh b/autologin/install.sh deleted file mode 100755 index 6ed6c12..0000000 --- a/autologin/install.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/sh - -DIR=$(dirname "$(readlink -f "$0")") -. "$DIR/../env.sh" - -echo 'Please enter autologin username (empty to skip): ' -read -r username -if [ -z "$username" ]; then - echo skip autologin setup -else - sudo mkdir -p /etc/systemd/system/getty@tty1.service.d - sed -r "s/USERNAME/$username/g" "$DIR/systemd/getty1-override.conf" | \ - sudo tee /etc/systemd/system/getty@tty1.service.d/override.conf -fi diff --git a/autologin/systemd/getty1-override.conf b/autologin/systemd/getty1-override.conf deleted file mode 100644 index e28931c..0000000 --- a/autologin/systemd/getty1-override.conf +++ /dev/null @@ -1,4 +0,0 @@ -[Service] -ExecStart= -#ExecStart=-/usr/bin/agetty --autologin USERNAME --noclear %I $TERM -ExecStart=-/sbin/agetty --autologin USERNAME --noclear %I $TERM diff --git a/autologin/systemd/lock-on-suspend.service b/autologin/systemd/lock-on-suspend.service deleted file mode 100644 index b5c19f0..0000000 --- a/autologin/systemd/lock-on-suspend.service +++ /dev/null @@ -1,10 +0,0 @@ -[Unit] -Description=Lock on suspend -Before=sleep.target - -[Service] -ExecStart=/usr/bin/loginctl lock-sessions -ExecStartPost=/usr/bin/sleep 2 - -[Install] -WantedBy=sleep.target diff --git a/optim/ls-vscode-cache.fish b/bin/ls_vsc_cache similarity index 100% rename from optim/ls-vscode-cache.fish rename to bin/ls_vsc_cache diff --git a/optim/bbr.sh b/cli/bbr.sh similarity index 100% rename from optim/bbr.sh rename to cli/bbr.sh diff --git a/bin/consolefont-for-hidpi b/cli/consolefont.sh similarity index 100% rename from bin/consolefont-for-hidpi rename to cli/consolefont.sh diff --git a/fish/install.sh b/cli/fish.sh similarity index 59% rename from fish/install.sh rename to cli/fish.sh index f825391..f2460b4 100755 --- a/fish/install.sh +++ b/cli/fish.sh @@ -1,25 +1,27 @@ #!/bin/sh +set -e DIR=$(dirname "$(readlink -f "$0")") . "$DIR/../env.sh" -# install fish shell -echo Installing fish shell +log 'Setting up shell' + case "$PM" in apt) ! command -v pip3 && "$PDIR/python/install.sh" sudo add-apt-repository ppa:fish-shell/release-3 -y sudo apt update - sudo apt install fish libnotify-bin xdotool silversearcher-ag dash bat -y - [ ! -d "$HOME/.fzf" ] && git clone --depth 1 https://github.com/junegunn/fzf.git "$HOME/.fzf" - ~/.fzf/install --all + sudo apt install fish silversearcher-ag dash bat -y lnsf /usr/bin/batcat "$HOME/.local/bin/bat" + intorepo https://github.com/junegunn/fzf.git "$HOME/.fzf" + ./install --all + exitrepo ;; pacman) - sudo pacman -S --needed --needed fish xdotool fzf the_silver_searcher dash bat + sudo pacman -S --noconfirm --needed fish the_silver_searcher dash bat fzf # prevent bash upgradation relink /bin/sh sudo mkdir -p /etc/pacman.d/hooks - cat <<' EOT' | sed 's/^ *//' | sudo tee /etc/pacman.d/sh-is-dash.hook + echo " [Trigger] Type = Package Operation = Install @@ -31,34 +33,31 @@ case "$PM" in When = PostTransaction Exec = /usr/bin/ln -sfT dash /usr/bin/sh Depends = dash - EOT + " | sed 's/^ *//' | sudo tee /etc/pacman.d/sh-is-dash.hook >/dev/null ;; esac -# install bat theme +log 'Setting up bat' BAT_THEMES="$(bat --config-dir)/themes" BAT_GRUVBOX="$BAT_THEMES/gruvbox" -if [ ! -d "$BAT_GRUVBOX" ]; then +if [ ! -d "$BAT_GRUVBOX" ]; then mkdir -p "$BAT_THEMES" - git clone --depth 1 https://github.com/peaceant/gruvbox.git "$BAT_GRUVBOX" + git_clone https://github.com/peaceant/gruvbox.git "$BAT_GRUVBOX" fi -# use dash as default shell because it much faster and will be used vim-fugitive, -# leads to a much faster responsive speed +log 'Setting up dash as default shell' sudo /usr/bin/ln -sfT dash /usr/bin/sh [ "$(awk -F':' '/^'"$USER"'/{print $7}' /etc/passwd)" != "/bin/sh" ] && chsh -s /bin/sh -# symlink config -[ -L "$XDG_CONFIG_HOME/fish" ] && rm -rf "$XDG_CONFIG_HOME/fish" - -lnsf "$DIR/config/config.fish" "$XDG_CONFIG_HOME/fish/config.fish" -lnsf "$DIR/config/functions/fish_prompt.fish" "$XDG_CONFIG_HOME/fish/functions/fish_prompt.fish" -lnsf "$DIR/config/functions/fish_right_prompt.fish" "$XDG_CONFIG_HOME/fish/functions/fish_right_prompt.fish" -lnsf "$DIR/config/functions/fisher.fish" "$XDG_CONFIG_HOME/fish/functions/fisher.fish" -lnsf "$DIR/config/functions/r.fish" "$XDG_CONFIG_HOME/fish/functions/r.fish" -lnsf "$DIR/config/functions/append_paths.fish" "$XDG_CONFIG_HOME/fish/functions/append_paths.fish" -lnsf "$DIR/config/functions/source_files.fish" "$XDG_CONFIG_HOME/fish/functions/source_files.fish" +log 'Setting up fish' +lnsf "$DIR/fish/config.fish" "$XDG_CONFIG_HOME/fish/config.fish" +lnsf "$DIR/fish/functions/fish_prompt.fish" "$XDG_CONFIG_HOME/fish/functions/fish_prompt.fish" +lnsf "$DIR/fish/functions/fish_right_prompt.fish" "$XDG_CONFIG_HOME/fish/functions/fish_right_prompt.fish" +lnsf "$DIR/fish/functions/fisher.fish" "$XDG_CONFIG_HOME/fish/functions/fisher.fish" +lnsf "$DIR/fish/functions/r.fish" "$XDG_CONFIG_HOME/fish/functions/r.fish" +lnsf "$DIR/fish/functions/append_paths.fish" "$XDG_CONFIG_HOME/fish/functions/append_paths.fish" +lnsf "$DIR/fish/functions/source_files.fish" "$XDG_CONFIG_HOME/fish/functions/source_files.fish" # install plugins # for better keybinding: C-o open file with $EDITOR / C-r search history / C-g open with xdg-open @@ -92,4 +91,4 @@ set -U fish_pager_color_completion normal set -U fish_pager_color_description B3A06D yellow set -U fish_pager_color_prefix white --bold --underline set -U fish_pager_color_progress brwhite --background=cyan -' +' > /dev/null diff --git a/fish/config/config.fish b/cli/fish/config.fish similarity index 100% rename from fish/config/config.fish rename to cli/fish/config.fish diff --git a/fish/config/functions/append_paths.fish b/cli/fish/functions/append_paths.fish similarity index 100% rename from fish/config/functions/append_paths.fish rename to cli/fish/functions/append_paths.fish diff --git a/fish/config/functions/clean_taobao_link.fish b/cli/fish/functions/clean_taobao_link.fish similarity index 100% rename from fish/config/functions/clean_taobao_link.fish rename to cli/fish/functions/clean_taobao_link.fish diff --git a/fish/config/functions/fish_prompt.fish b/cli/fish/functions/fish_prompt.fish similarity index 100% rename from fish/config/functions/fish_prompt.fish rename to cli/fish/functions/fish_prompt.fish diff --git a/fish/config/functions/fish_right_prompt.fish b/cli/fish/functions/fish_right_prompt.fish similarity index 100% rename from fish/config/functions/fish_right_prompt.fish rename to cli/fish/functions/fish_right_prompt.fish diff --git a/fish/config/functions/fisher.fish b/cli/fish/functions/fisher.fish similarity index 100% rename from fish/config/functions/fisher.fish rename to cli/fish/functions/fisher.fish diff --git a/fish/config/functions/r.fish b/cli/fish/functions/r.fish similarity index 100% rename from fish/config/functions/r.fish rename to cli/fish/functions/r.fish diff --git a/fish/config/functions/source_files.fish b/cli/fish/functions/source_files.fish similarity index 100% rename from fish/config/functions/source_files.fish rename to cli/fish/functions/source_files.fish diff --git a/fish/config/functions/sync_ssh_config.fish b/cli/fish/functions/sync_ssh_config.fish similarity index 100% rename from fish/config/functions/sync_ssh_config.fish rename to cli/fish/functions/sync_ssh_config.fish diff --git a/cli/install.sh b/cli/install.sh new file mode 100755 index 0000000..7aa9b5b --- /dev/null +++ b/cli/install.sh @@ -0,0 +1,11 @@ +#!/bin/sh + +set -e +DIR=$(dirname "$(readlink -f "$0")") +. "$DIR/../env.sh" + +. "$DIR/mirrors.sh" +. "$DIR/fish.sh" +. "$DIR/vim.sh" +. "$DIR/ranger.sh" +. "$DIR/tmux.sh" diff --git a/cli/mirrors.sh b/cli/mirrors.sh new file mode 100755 index 0000000..f9e5633 --- /dev/null +++ b/cli/mirrors.sh @@ -0,0 +1,44 @@ +#!/bin/sh + +set -e +DIR=$(dirname "$(readlink -f "$0")") +. "$DIR/../env.sh" + +log 'Setting up mirror list' + +! in_china && echo 'Skip mirrors configuration' && return + +# setup package mirror for CHINA +case "$PM" in + apt) + # backup original sources.list + [ ! -f /etc/apt/sources.list.bak ] && \ + sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak + # replace with aliyun mirror + awk '$0 ~ /^deb/ {$2="https://mirrors.aliyun.com/ubuntu/"; print}' /etc/apt/sources.list.bak \ + | sudo tee /etc/apt/sources.list + ;; + pacman) + COUNTRY=China + [ ! -f /etc/pacman.d/mirrorlist.bak ] && \ + sudo cp /etc/pacman.d/mirrorlist /etc/pacman.d/mirrorlist.bak + awk ' + { + if (NR < 7) { + print + } else if ($0 == "## '$COUNTRY'") { + print + matched = 1 + } else if (matched == 1) { + print + matched = 0 + } else { + buffer = buffer "\n" $0 + } + } + END { print buffer } + ' /etc/pacman.d/mirrorlist.bak | sudo tee /etc/pacman.d/mirrorlist >/dev/null + ;; +esac + + diff --git a/cli/ranger.sh b/cli/ranger.sh new file mode 100755 index 0000000..5d93248 --- /dev/null +++ b/cli/ranger.sh @@ -0,0 +1,33 @@ +#!/bin/sh + +set -e +DIR=$(dirname "$(readlink -f "$0")") +. "$DIR/../env.sh" + +log 'Setting up ranger' + +# install ranger +case "$PM" in + apt) + # atool/p7zip-full for archive previewing/extracting etc + sudo apt install -y atool p7zip-full unrar + ! has_cmd pip3 && "$PDIR/devel/python.sh" + sudo pip3 install ranger-fm ueberzug + ;; + pacman) + sudo pacman -S --noconfirm --needed atool p7zip unrar + ! has_cmd pip && "$PDIR/devel/python.sh" + sudo pip install ranger-fm ueberzug + ;; +esac + +# linking configuration files +lnsf "$DIR/ranger/commands.py" "$XDG_CONFIG_HOME/ranger/commands.py" +lnsf "$DIR/ranger/rc.conf" "$XDG_CONFIG_HOME/ranger/rc.conf" +lnsf "$DIR/ranger/scope.sh" "$XDG_CONFIG_HOME/ranger/scope.sh" +lnsf "$DIR/ranger/colorschemes/solarizedmod.py" "$XDG_CONFIG_HOME/ranger/colorschemes/solarizedmod.py" + +# install devicons +DEVICONS_DIR=$HOME/.config/ranger/plugins/ranger_devicons +[ ! -d "$DEVICONS_DIR" ] && \ + git clone https://gitee.com/klesh/ranger_devicons.git "$DEVICONS_DIR" diff --git a/ranger/config/colorschemes/solarizedmod.py b/cli/ranger/colorschemes/solarizedmod.py similarity index 100% rename from ranger/config/colorschemes/solarizedmod.py rename to cli/ranger/colorschemes/solarizedmod.py diff --git a/ranger/config/commands.py b/cli/ranger/commands.py similarity index 100% rename from ranger/config/commands.py rename to cli/ranger/commands.py diff --git a/ranger/config/rc.conf b/cli/ranger/rc.conf similarity index 100% rename from ranger/config/rc.conf rename to cli/ranger/rc.conf diff --git a/ranger/config/scope.sh b/cli/ranger/scope.sh similarity index 100% rename from ranger/config/scope.sh rename to cli/ranger/scope.sh diff --git a/gui/sshd.sh b/cli/sshd.sh similarity index 77% rename from gui/sshd.sh rename to cli/sshd.sh index 7335a53..e87720c 100755 --- a/gui/sshd.sh +++ b/cli/sshd.sh @@ -1,8 +1,11 @@ #!/bin/sh +set -e DIR=$(dirname "$(readlink -f "$0")") . "$DIR/../env.sh" +log 'Setting up ssh server' + # install sshd case "$PM" in apt) @@ -10,7 +13,7 @@ case "$PM" in openssh-server ;; pacman) - sudo pacman -S --needed \ + sudo pacman -S --noconfirm --needed \ openssh ;; esac diff --git a/tmux/install.sh b/cli/tmux.sh similarity index 71% rename from tmux/install.sh rename to cli/tmux.sh index 3a866e0..5ff0b4b 100755 --- a/tmux/install.sh +++ b/cli/tmux.sh @@ -4,12 +4,12 @@ set -e DIR=$(dirname "$(readlink -f "$0")") . "$DIR/../env.sh" -TMUX_VER=3.1b +log 'Setting up tmux' -# install ranger case "$PM" in apt) - if command -v tmux 2>/dev/null && [ "$(tmux -V)" != "tmux $TMUX_VER" ]; then + TMUX_VER=3.1b + if ! has_cmd tmux || [ "$(tmux -V)" != "tmux $TMUX_VER" ]; then sudo apt install libevent-dev libncurses5-dev bison autoconf bc -y TMUX_SRC_URL=https://github.com/tmux/tmux/releases/download/$TMUX_VER/tmux-$TMUX_VER.tar.gz if in_china; then @@ -28,11 +28,11 @@ case "$PM" in fi ;; pacman) - sudo pacman -S --needed tmux bc + sudo pacman -S --noconfirm --needed tmux bc ;; esac # symlink configuration -lnsf "$DIR/tmux.conf" ~/.tmux.conf -lnsf "$DIR/config/tmux2.8.conf" "$XDG_CONFIG_HOME/tmux/tmux2.8.conf" -lnsf "$DIR/config/tmux2.9.conf" "$XDG_CONFIG_HOME/tmux/tmux2.9.conf" +lnsf "$DIR/tmux/tmux.conf" "$HOME/.tmux.conf" +lnsf "$DIR/tmux/tmux2.8.conf" "$XDG_CONFIG_HOME/tmux/tmux2.8.conf" +lnsf "$DIR/tmux/tmux2.9.conf" "$XDG_CONFIG_HOME/tmux/tmux2.9.conf" diff --git a/tmux/tmux.conf b/cli/tmux/tmux.conf similarity index 95% rename from tmux/tmux.conf rename to cli/tmux/tmux.conf index 3e548e2..de1bb65 100644 --- a/tmux/tmux.conf +++ b/cli/tmux/tmux.conf @@ -64,9 +64,6 @@ bind M \ set -g @yank_action 'copy-pipe' set -g @plugin 'tmux-plugins/tmux-yank' -#set -g @plugin 'kristijanhusak/tmux-simple-git-status' -set -g @plugin 'klesh/tmux-open' -set -g @plugin 'tmux-plugins/tmux-copycat' if "test ! -d ~/.tmux/plugins/tpm" \ "run 'git clone --depth 1 https://github.com/tmux-plugins/tpm ~/.tmux/plugins/tpm && ~/.tmux/plugins/tpm/bin/install_plugins'" # prefix + I diff --git a/tmux/config/tmux2.8.conf b/cli/tmux/tmux2.8.conf similarity index 100% rename from tmux/config/tmux2.8.conf rename to cli/tmux/tmux2.8.conf diff --git a/tmux/config/tmux2.9.conf b/cli/tmux/tmux2.9.conf similarity index 100% rename from tmux/config/tmux2.9.conf rename to cli/tmux/tmux2.9.conf diff --git a/cli/vim.sh b/cli/vim.sh new file mode 100755 index 0000000..f17408e --- /dev/null +++ b/cli/vim.sh @@ -0,0 +1,33 @@ +#!/bin/sh + +set -e +DIR=$(dirname "$(readlink -f "$0")") +. "$DIR/../env.sh" + +log 'Setting up vim' + +# check dependencies +if [ "$VIM_MODE" = "enhanced" ]; then + ! has_cmd npm && "$PDIR/devel/nodejs.sh" + ! has_cmd pip && "$PDIR/devel/python.sh" +fi + +# install nvim +case "$PM" in + apt) + sudo add-apt-repository ppa:neovim-ppa/stable -y + sudo apt update + sudo apt install -y neovim + [ "$VIM_MODE" = "enhanced" ] && sudo pip3 install pyvim neovim + ;; + pacman) + sudo pacman -S --noconfirm --needed neovim + [ "$VIM_MODE" = "enhanced" ] && sudo pip install pyvim neovim + ;; +esac + +# symlink configuration +lnsf "$DIR/vim/init.vim" "$XDG_CONFIG_HOME/nvim/init.vim" +lnsf "$DIR/vim/coc-settings.json" "$XDG_CONFIG_HOME/nvim/coc-settings.json" +lnsf "$DIR/vim/coc-settings.json" "$HOME/.vim/coc-settings.json" +lnsf "$DIR/vim/init.vim" "$HOME/.vimrc" diff --git a/nvim/config/coc-settings.json b/cli/vim/coc-settings.json similarity index 100% rename from nvim/config/coc-settings.json rename to cli/vim/coc-settings.json diff --git a/nvim/config/ginit.vim b/cli/vim/ginit.vim similarity index 100% rename from nvim/config/ginit.vim rename to cli/vim/ginit.vim diff --git a/nvim/config/init.vim b/cli/vim/init.vim similarity index 100% rename from nvim/config/init.vim rename to cli/vim/init.vim diff --git a/nvim/config/tex.vim b/cli/vim/tex.vim similarity index 100% rename from nvim/config/tex.vim rename to cli/vim/tex.vim diff --git a/apps/wd-passport.sh b/cli/wdpassport.sh similarity index 100% rename from apps/wd-passport.sh rename to cli/wdpassport.sh diff --git a/deeplearning/install.sh b/devel/deeplearning.sh similarity index 100% rename from deeplearning/install.sh rename to devel/deeplearning.sh diff --git a/apps/docker-arm.sh b/devel/docker-arm.sh similarity index 100% rename from apps/docker-arm.sh rename to devel/docker-arm.sh diff --git a/apps/docker.sh b/devel/docker.sh similarity index 85% rename from apps/docker.sh rename to devel/docker.sh index db1210a..71cceb4 100755 --- a/apps/docker.sh +++ b/devel/docker.sh @@ -9,12 +9,12 @@ case "$PM" in apt) # snap docker will intefere native docker.io, must be dealt with sudo snap remove --purge docker - sudo apt install -y docker.io docker-compose - ! command -v pip3 && "$PDIR/python/install.sh" + sudo apt install -y docker.io + ! has_cmd pip && . "$PDIR/python/install.sh" sudo pip3 install docker-compose ;; pacman) - sudo pacman -S --needed docker docker-compose + sudo pacman -S --noconfirm --needed docker docker-compose ;; esac diff --git a/devel/ftgfw.sh b/devel/ftgfw.sh new file mode 100755 index 0000000..5cfd2a2 --- /dev/null +++ b/devel/ftgfw.sh @@ -0,0 +1,22 @@ +#!/bin/sh + + +if [ ! -f /tmp/docker.zip ]; then + echo "Please enter nextcloud hostname:" + read -r HOSTNAME + + echo "Please enter nextcloud account:" + read -r ACCOUNT + + echo "Please enter nextcloud password:" + stty -echo + read -r PASSWORD + stty echo + + curl -u "$ACCOUNT:$PASSWORD" -Lo /tmp/docker.zip "https://$HOSTNAME:8443/index.php/apps/files/ajax/download.php?dir=%2F&files=docker" +fi + +DEST_DIR=$HOME/Nextcloud +mkdir -p "$DEST_DIR" +7z x -o"$DEST_DIR" /tmp/docker.zip + diff --git a/apps/k8s.sh b/devel/k8s.sh similarity index 100% rename from apps/k8s.sh rename to devel/k8s.sh diff --git a/apps/mongocli.sh b/devel/mongocli.sh similarity index 100% rename from apps/mongocli.sh rename to devel/mongocli.sh diff --git a/devel/nodejs.sh b/devel/nodejs.sh new file mode 100755 index 0000000..f953a43 --- /dev/null +++ b/devel/nodejs.sh @@ -0,0 +1,88 @@ +#!/bin/sh + +DIR=$(dirname "$(readlink -f "$0")") +. "$DIR/../env.sh" + + +FILES_PATH=$PREFIX/nodejs +NODE_BIN=$PREFIX/bin/node +NODE_URL=https://nodejs.org/dist +NODE_VERSION=v14.15.1 +in_china && NODE_URL=https://npm.taobao.org/mirrors/node + +log "Setting up nodejs" + +lspkgs() { + curl -s $NODE_URL/index.json \ + | jq '.[] | "\(.version) \(if .lts then "(lts)" else "" end)"' -r +} + +uninstall() { + [ -f "$FILES_PATH" ] \ + && tac "$FILES_PATH" | grep -v '/$' | xargs sudo rm -f +} + +install() { + VERSION=$1 + ARCH=x86 + [ -x "$NODE_BIN" ] && [ "$("$NODE_BIN" --version)" = "$VERSION" ] && exit 0 + case "$(uname -m)" in + x86_64) + ARCH=x64 + ;; + armv6|armv6l) + ARCH=armv6l + ;; + armv7|armv7l) + ARCH=armv7l + ;; + armv8|armv8l|aarch64) + ARCH=arm64 + ;; + esac + NAME=node-$VERSION-linux-$ARCH.tar.gz + # download package + echo wget -O "/tmp/$NAME" "$NODE_URL/$VERSION/$NAME" + wget -O "/tmp/$NAME" "$NODE_URL/$VERSION/$NAME" + # remove previous installed + uninstall + # install and save extracted paths + sudo tar zxvf "/tmp/$NAME" --strip 1 -C "$PREFIX" \ + | sed -r "s|^[^/]+/|$PREFIX/|" \ + | sudo tee "$FILES_PATH" >/dev/null + # remove download path + rm "/tmp/$NAME" + in_china && sudo npm install -g cnpm --registry=https://registry.npm.taobao.org +} + + +case "$1" in + ls|list) + lspkgs | less + ;; + uninstall) + uninstall + ;; + '') + install "$NODE_VERSION" + ;; + *) + install "$1" + ;; +esac + + +#yarnpkg config set registry https://registry.npm.taobao.org --global && \ +#yarnpkg config set disturl https://npm.taobao.org/dist --global && \ +#yarnpkg config set sass_binary_site https://npm.taobao.org/mirrors/node-sass --global && \ +#yarnpkg config set electron_mirror https://npm.taobao.org/mirrors/electron/ --global && \ +#yarnpkg config set puppeteer_download_host https://npm.taobao.org/mirrors --global && \ +#yarnpkg config set chromedriver_cdnurl https://npm.taobao.org/mirrors/chromedriver --global && \ +#yarnpkg config set operadriver_cdnurl https://npm.taobao.org/mirrors/operadriver --global && \ +#yarnpkg config set phantomjs_cdnurl https://npm.taobao.org/mirrors/phantomjs --global && \ +#yarnpkg config set selenium_cdnurl https://npm.taobao.org/mirrors/selenium --global && \ +#yarnpkg config set sqlite3_binary_host_mirror https://foxgis.oss-cn-shanghai.aliyuncs.com/ --global && \ +#yarnpkg config set profiler_binary_host_mirror https://npm.taobao.org/mirrors/node-inspector/ --global && \ +#yarnpkg config set chromedriver_cdnurl https://cdn.npm.taobao.org/dist/chromedriver --global && \ +#yarnpkg config set node_inspector_cdnurl https://npm.taobao.org/mirrors/node-inspector --global && \ +#yarnpkg config set sentrycli_cdnurl https://npm.taobao.org/mirrors/sentry-cli diff --git a/devel/python.sh b/devel/python.sh new file mode 100755 index 0000000..b4e6b6b --- /dev/null +++ b/devel/python.sh @@ -0,0 +1,39 @@ +#!/bin/sh + +DIR=$(dirname "$(readlink -f "$0")") +. "$DIR/../env.sh" + +log "Setting up python3" + +if in_china; then + + # config pip mirror for CHINA + mkdir -p "$HOME/.pip" + echo " + [global] + index-url = https://mirrors.aliyun.com/pypi/simple + " | sed -r 's/^ *//' | sudo tee "/etc/pip.conf" +fi + +# install python3 +case "$PM" in + apt) + #for older ubuntu distro + #sudo add-apt-repository ppa:deadsnakes/ppa + #sudo apt-get update + #sudo apt-get install python3.8 + #sudo apt install python3.8-distutils + #sudo python3.8 -m pip install --upgrade pip setuptools wheel + sudo apt install python3 python3-pip python-is-python3 + ;; + pacman) + sudo pacman -S --noconfirm --needed python python-pip + ;; +esac + +# enable auto_activation plugin for virtualfish +if has_fish; then + sudo pip install virtualfish + fish -c "yes | vf install && vf addplugins auto_activation" +fi + diff --git a/devel/rust.sh b/devel/rust.sh new file mode 100755 index 0000000..f612aab --- /dev/null +++ b/devel/rust.sh @@ -0,0 +1,35 @@ +#!/bin/sh + +DIR=$(dirname "$(readlink -f "$0")") +. "$DIR/../env.sh" + +log "Setting up rust" + +if in_china; then + export RUSTUP_DIST_SERVER=https://mirrors.ustc.edu.cn/rust-static + export RUSTUP_UPDATE_ROOT=https://mirrors.ustc.edu.cn/rust-static/rustup + + if command -v fish >/dev/null; then + echo " + set -x RUSTUP_DIST_SERVER $RUSTUP_DIST_SERVER + set -x RUSTUP_UPDATE_ROOT $RUSTUP_UPDATE_ROOT + " | sed 's/^ *//' > "$XDG_CONFIG_HOME/fish/conf.d/rustup.fish" + + fi + + # setup cargo mirrors + [ ! -f "$HOME/.cargo/config" ] && mkdir -p "$HOME/.cargo" && echo " + [source.crates-io] + replace-with = 'ustc' + + [source.ustc] + registry = \"git://mirrors.ustc.edu.cn/crates.io-index\" + " | sed 's/^ *//' > "$HOME/.cargo/config" +fi + +[ ! -f "$HOME/.cargo/bin/rustup" ] \ + && curl -sSf https://cdn.jsdelivr.net/gh/rust-lang-nursery/rustup.rs/rustup-init.sh | sh + +command -v fish >/dev/null && echo " + source $HOME/.cargo/env +" | sed 's/^ *//' > "$XDG_CONFIG_HOME/fish/conf.d/cargo.fish" diff --git a/env.sh b/env.sh index 8320efa..cf8706e 100755 --- a/env.sh +++ b/env.sh @@ -1,40 +1,27 @@ #!/bin/sh set -e +[ "$ENVSHED" = "yes" ] && return +ENVSHED=yes PM=n/a XDG_CONFIG_HOME=${XDG_CONFIG_HOME-"$HOME/.config"} PREFIX=/usr/local PDIR=$(dirname "${DIR-$0}") GITHUB_PROXY=${GITHUB_PROXY-$HTTPS_PROXY} -echo "dir: $DIR" -echo "parent dir: $PDIR" -echo "prefix dir: $PREFIX" -sudo mkdir -p $PREFIX - -if command -v pacman > /dev/null; then - PM=pacman -elif command -v apt > /dev/null; then - PM=apt -fi - -if [ "$PM" = "n/a" ]; then - echo "Unsupported Package Manager" - exit 1 -fi - -in_china () { +in_china() { if [ -z "$IS_CHINA" ]; then IS_CHINA=no - if curl -q myip.ipip.net | grep '中国' > /dev/null; then + if curl -s myip.ipip.net | grep -qF '中国' > /dev/null; then IS_CHINA=yes fi fi - [ "$IS_CHINA" = "no" ] && return 1 + [ "$IS_CHINA" = "no" ] && echo "in_china: no" && return 1 + echo "in_china: yes" return 0 } -lnsf () { +lnsf() { [ "$#" -ne 2 ] && echo "lnsf " && return 1 TARGET=$(readlink -f "$1") || (echo failed: readlink -f "$1" ; return 1) SYMLNK=$2 @@ -48,11 +35,11 @@ lnsf () { ln -sf "$TARGET" "$SYMLNK" } -has_bluetooth () { +has_bluetooth() { dmesg | grep -i bluetooth } -eqv () { +eqv() { VERSION_PATH=$1 VERSION=$2 [ ! -f "$VERSION_PATH" ] && return 1 @@ -60,24 +47,51 @@ eqv () { [ "$VERSION" = "$VERSION2" ] } +git_clone() { + mkdir -p "$(dirname "$2")" + [ -d "$2" ] && return + echo "$1" | grep -qF 'github.com' && HTTPS_PROXY=$GITHUB_PROXY git clone --depth 1 "$1" "$2" + git clone --depth 1 "$1" "$2" +} + intorepo() { ODIR=$(pwd) REPO=$2 - if [ ! -d "$REPO" ]; then - HTTPS_PROXY=$GITHUB_PROXY git clone --depth 1 "$1" "$REPO" - cd "$REPO" - else - cd "$REPO" - git pull - fi + git_clone "$1" "$REPO" + cd "$REPO" } exitrepo() { cd "$ODIR" } +log() { + printf "\n\033[32m%s\033[0m\n" "$@" +} -# install basic common utilities +has_cmd() { + command -v "$1" >/dev/null 2>&1 +} + +has_fish() { + has_cmd "$1" +} + + +sudo mkdir -p $PREFIX + +if has_cmd pacman; then + PM=pacman +elif has_cmd apt; then + PM=apt +fi + +if [ "$PM" = "n/a" ]; then + echo "Unsupported Package Manager" + exit 1 +fi + +log "Installing basic utilities" case "$PM" in apt) sudo apt install \ @@ -88,14 +102,14 @@ case "$PM" in man sudo ;; pacman) - sudo pacman -S --needed --needed \ + sudo pacman -S --noconfirm --needed \ base-devel \ unzip p7zip \ openssh \ curl wget \ man sudo # install yay - if ! command -v yay; then + if ! command -v yay >/dev/null; then git clone --depth 1 https://aur.archlinux.org/yay.git /tmp/yay cd /tmp/yay makepkg -si @@ -104,3 +118,10 @@ case "$PM" in ;; esac + +log "Environments" +echo " PM : $PM" +echo " DIR : $DIR" +echo " PDIR : $PDIR" +echo " PREFIX : $PREFIX" +echo " GITHUB_PROXY : $GITHUB_PROXY" diff --git a/gui/autologin.sh b/gui/autologin.sh new file mode 100755 index 0000000..f96b41a --- /dev/null +++ b/gui/autologin.sh @@ -0,0 +1,19 @@ +#!/bin/sh + +set -e +DIR=$(dirname "$(readlink -f "$0")") +. "$DIR/../env.sh" + +echo 'Please enter autologin username (empty to skip): ' +read -r LOGIN +if [ -z "$LOGIN" ]; then + echo skip autologin setup + return +fi + +sudo mkdir -p /etc/systemd/system/getty@tty1.service.d +echo " +[Service] +ExecStart= +ExecStart=-/sbin/agetty --autologin $LOGIN --noclear %I \$TERM +" | sudo tee /etc/systemd/system/getty@tty1.service.d/override.conf > /dev/null diff --git a/suckless/config/autorandr/postswitch b/gui/autorandr/postswitch similarity index 100% rename from suckless/config/autorandr/postswitch rename to gui/autorandr/postswitch diff --git a/gui/content/dunstrc b/gui/dunst/dunstrc similarity index 100% rename from gui/content/dunstrc rename to gui/dunst/dunstrc diff --git a/suckless/config/dwm/autostart b/gui/dwm/autostart similarity index 100% rename from suckless/config/dwm/autostart rename to gui/dwm/autostart diff --git a/gui/font.sh b/gui/font.sh new file mode 100755 index 0000000..e8175a4 --- /dev/null +++ b/gui/font.sh @@ -0,0 +1,71 @@ +#!/bin/sh + +set -e +DIR=$(dirname "$(readlink -f "$0")") +. "$DIR/../env.sh" + +log 'Setting up fonts' + +case "$PM" in + apt) + # fonts + sudo apt install -y \ + fonts-urw-base35 \ + fonts-cascadia-code \ + fonts-wqy-microhei \ + fonts-symbola \ + fonts-dejavu-core \ + gucharmap + ;; + pacman) + # fonts + sudo pacman -S --noconfirm --needed \ + freetype2 \ + gsfonts \ + ttf-cascadia-code \ + ttf-dejavu \ + gucharmap + # official wqy-microhei package doesn't fix the Korean Glyphs stacking bug + # https://code.google.com/p/chromium/issues/detail?id=233851 + # use debian package instead + DEB_PKG_NAME=fonts-wqy-microhei_0.2.0-beta-3_all.deb + [ ! -f "/tmp/$DEB_PKG_NAME" ] && \ + wget http://mirrors.163.com/debian/pool/main/f/fonts-wqy-microhei/$DEB_PKG_NAME -O /tmp/$DEB_PKG_NAME + ar p "/tmp/$DEB_PKG_NAME" data.tar.xz | sudo tar Jxv -C / + # install symbola for plain emojis(no-color) for st + ! fc-list | grep -qi symbola && yay -S --noconfirm --needed ttf-symbola-free + ;; +esac + + +# install hermit nerd font +install_nerdfont () { + grep -F "$*" /usr/local/share/fonts/nerdfont && return + ORIGIN_NAME=$1 + PATCHED_PAT=$2 + VERSION=$3 + NAME=$ORIGIN_NAME-$VERSION.zip + LOCAL_REPO_PATH=/tmp/nerd-font/$ORIGIN_NAME + # shortcircuit if font already in system + fc-list | grep -F "$PATCHED_PAT" | grep -i nerd && return + # clone single branch from gitee + git clone --single-branch --branch "$ORIGIN_NAME" --depth 1 \ + https://gitee.com/klesh/nerd-fonts.git \ + "$LOCAL_REPO_PATH" + sudo 7z x -x!'*Windows*' -aoa "$LOCAL_REPO_PATH/$NAME" -o/usr/local/share/fonts + sudo chmod +rx /usr/local/share/fonts + echo "$*" | sudo tee -a /usr/local/share/fonts/nerdfont + rm -rf "$LOCAL_REPO_PATH" +} + +#install_nerdfont Hermit Hurmit v2.1.0 +install_nerdfont Agave agave v2.1.0 +#install_nerdfont CascadiaCode Caskaydia v2.1.0 +#install_nerdfont DaddyTimeMono DaddyTimeMono v2.1.0 + +log 'Setting up font rendering' +sudo ln -sf /etc/fonts/conf.avail/70-no-bitmaps.conf /etc/fonts/conf.d +sudo ln -sf /etc/fonts/conf.avail/10-sub-pixel-rgb.conf /etc/fonts/conf.d +sudo ln -sf /etc/fonts/conf.avail/11-lcdfilter-default.conf /etc/fonts/conf.d +sudo cp "$DIR/font/freetype2.sh" "/etc/profile.d/freetype2.sh" +sudo cp "$DIR/font/local.conf" "/etc/fonts/local.conf" diff --git a/gui/content/freetype2.sh b/gui/font/freetype2.sh similarity index 100% rename from gui/content/freetype2.sh rename to gui/font/freetype2.sh diff --git a/gui/content/local.conf b/gui/font/local.conf similarity index 100% rename from gui/content/local.conf rename to gui/font/local.conf diff --git a/gui/content/nerdfonticons b/gui/font/nerdfonticons similarity index 100% rename from gui/content/nerdfonticons rename to gui/font/nerdfonticons diff --git a/gui/install.sh b/gui/install.sh index 2f3ecf3..3dbbf5c 100755 --- a/gui/install.sh +++ b/gui/install.sh @@ -1,111 +1,26 @@ #!/bin/sh +set -e DIR=$(dirname "$(readlink -f "$0")") . "$DIR/../env.sh" -# install basic gui stuff, including fonts/system utilties/keyring etc -case "$PM" in - apt) - # fonts - sudo apt install \ - fonts-urw-base35 \ - fonts-cascadia-code \ - fonts-wqy-microhei \ - fonts-symbola \ - fonts-dejavu-core \ - dunst \ - gucharmap - # network manager - sudo apt install \ - network-manager network-manager-gnome - # bluetooth - if has_bluetooth; then - sudo apt install \ - bluez bluez-tools blueman pulseaudio-module-bluetooth - sudo systemctl enable bluetooth - sudo systemctl start bluetooth - # system utils - sudo apt install \ - exfat-utils \ - axel - fi - ;; - pacman) - # fonts - sudo pacman -S --needed \ - freetype2 \ - gsfonts \ - ttf-cascadia-code \ - ttf-dejavu \ - dunst \ - gucharmap - # official wqy-microhei package doesn't fix the Korean Glyphs stacking bug - # https://code.google.com/p/chromium/issues/detail?id=233851 - # use debian package instead - DEB_PKG_NAME=fonts-wqy-microhei_0.2.0-beta-3_all.deb - [ ! -f "/tmp/$DEB_PKG_NAME" ] && \ - wget http://mirrors.163.com/debian/pool/main/f/fonts-wqy-microhei/$DEB_PKG_NAME -O /tmp/$DEB_PKG_NAME - ar p "/tmp/$DEB_PKG_NAME" data.tar.xz | sudo tar Jxv -C / - # install symbola for plain emojis(no-color) for st - ! fc-list | grep -qi symbola && yay -S --needed ttf-symbola-free - # clipboard - sudo pacman -S --needed \ - xclip xsel - # keyring - sudo pacman -S --needed \ - gnome-keyring libsecret - # network manager - sudo pacman -S --needed \ - networkmanager network-manager-applet - # bluetooth - if has_bluetooth; then - sudo pacman -S --needed \ - bluez bluez-utils blueman pulseaudio-bluetooth xorg-xbacklight - sudo systemctl enable bluetooth - sudo systemctl start bluetooth - fi - # for setting up default programs: exo-preferred-applications - sudo pacman -S --needed \ - exfat-utils \ - axel \ - exo - ;; -esac +if [ "$PM" = "apt" ]; then + sudo systemctl disable systemd-networkd-wait-online + sudo systemctl mask systemd-networkd-wait-online + sudo systemctl disable cloud-init + sudo systemctl mask cloud-init + sudo systemctl disable cloud-config + sudo systemctl mask cloud-config + sudo systemctl disable gdm3 + sudo systemctl mask gdm3 +fi - -# install hermit nerd font -install_nerdfont () { - grep -F "$*" /usr/local/share/fonts/nerdfont && return - ORIGIN_NAME=$1 - PATCHED_PAT=$2 - VERSION=$3 - NAME=$ORIGIN_NAME-$VERSION.zip - LOCAL_REPO_PATH=/tmp/nerd-font/$ORIGIN_NAME - # shortcircuit if font already in system - fc-list | grep -F "$PATCHED_PAT" | grep -i nerd && return - # clone single branch from gitee - git clone --single-branch --branch "$ORIGIN_NAME" --depth 1 \ - https://gitee.com/klesh/nerd-fonts.git \ - "$LOCAL_REPO_PATH" - sudo 7z x -x!'*Windows*' -aoa "$LOCAL_REPO_PATH/$NAME" -o/usr/local/share/fonts - sudo chmod +rx /usr/local/share/fonts - echo "$*" | sudo tee -a /usr/local/share/fonts/nerdfont - rm -rf "$LOCAL_REPO_PATH" -} - -#install_nerdfont Hermit Hurmit v2.1.0 -install_nerdfont Agave agave v2.1.0 -#install_nerdfont CascadiaCode Caskaydia v2.1.0 -#install_nerdfont DaddyTimeMono DaddyTimeMono v2.1.0 - -# start network -sudo systemctl enable NetworkManager -sudo systemctl start NetworkManager - -# configuration -sudo ln -sf /etc/fonts/conf.avail/70-no-bitmaps.conf /etc/fonts/conf.d -sudo ln -sf /etc/fonts/conf.avail/10-sub-pixel-rgb.conf /etc/fonts/conf.d -sudo ln -sf /etc/fonts/conf.avail/11-lcdfilter-default.conf /etc/fonts/conf.d -sudo cp "$DIR/content/freetype2.sh" "/etc/profile.d/freetype2.sh" -sudo cp "$DIR/content/local.conf" "/etc/fonts/local.conf" -lnsf "$DIR/content/dunstrc" "$XDG_CONFIG_HOME/dunst/dunstrc" +. "$DIR/autologin.sh" +. "$DIR/suspendlock.sh" +. "$DIR/font.sh" +. "$DIR/sysutils.sh" +. "$DIR/picom.sh" +. "$DIR/office.sh" +. "$DIR/player.sh" +. "$DIR/theme.sh" +. "$DIR/suckless.sh" diff --git a/kvm/install.sh b/gui/kvm.sh similarity index 99% rename from kvm/install.sh rename to gui/kvm.sh index 1fb8785..2938e9f 100755 --- a/kvm/install.sh +++ b/gui/kvm.sh @@ -1,5 +1,6 @@ #!/bin/sh +set -e DIR=$(dirname "$(readlink -f "$0")") . "$DIR/../env.sh" diff --git a/player/config/mpd/mpd.conf b/gui/mpd/mpd.conf similarity index 100% rename from player/config/mpd/mpd.conf rename to gui/mpd/mpd.conf diff --git a/player/config/mpv/mpv.conf b/gui/mpv/mpv.conf similarity index 100% rename from player/config/mpv/mpv.conf rename to gui/mpv/mpv.conf diff --git a/player/config/mpv/scripts/organize.lua b/gui/mpv/scripts/organize.lua similarity index 100% rename from player/config/mpv/scripts/organize.lua rename to gui/mpv/scripts/organize.lua diff --git a/player/config/ncmpcpp/bindings b/gui/ncmpcpp/bindings similarity index 100% rename from player/config/ncmpcpp/bindings rename to gui/ncmpcpp/bindings diff --git a/player/config/ncmpcpp/config b/gui/ncmpcpp/config similarity index 100% rename from player/config/ncmpcpp/config rename to gui/ncmpcpp/config diff --git a/gui/office.sh b/gui/office.sh new file mode 100755 index 0000000..972b605 --- /dev/null +++ b/gui/office.sh @@ -0,0 +1,36 @@ +#!/bin/sh + +set -e +DIR=$(dirname "$(readlink -f "$0")") +. "$DIR/../env.sh" + +log 'Settingup office tools: libreoffice keepassxc nextcloud chrome zathura gimp sxiv' + +case "$PM" in + apt) + sudo add-apt-repository -y ppa:libreoffice/libreoffice-7-0 + sudo add-apt-repository -y ppa:phoerious/keepassxc + sudo add-apt-repository -y ppa:nextcloud-devs/client + sudo apt update + sudo apt install -y \ + google-chrome-stable \ + zathura zathura-pdf-poppler sxiv \ + gimp \ + libreoffice \ + keepassxc \ + nextcloud-client + ;; + pacman) + # fonts + sudo pacman -S --noconfirm --needed \ + chromium \ + zathura zathura-pdf-mupdf sxiv \ + gimp \ + libreoffice-fresh \ + keepassxc \ + nextcloud-client + ;; +esac + +lnsf "$DIR/zathura/zathurarc" "$XDG_CONFIG_HOME/zathura/zathurarc" +rm -f "$HOME/.local/share/applications/chrome-*.desktop" diff --git a/picom/install.sh b/gui/picom.sh similarity index 72% rename from picom/install.sh rename to gui/picom.sh index 3fec352..6f6327b 100755 --- a/picom/install.sh +++ b/gui/picom.sh @@ -4,29 +4,30 @@ set -e DIR=$(dirname "$(readlink -f "$0")") . "$DIR/../env.sh" +log 'Setting up picom' # install dpes case "$PM" in apt) # install build tools - ! command -v pip3 && "$PDIR/python/install.sh" + ! has_cmd pip3 && . "$PDIR/python/install.sh" sudo pip3 install meson # install dependencies sudo apt install -y ninja-build libxext-dev libxcb1-dev libxcb-damage0-dev libxcb-xfixes0-dev libxcb-shape0-dev libxcb-render-util0-dev libxcb-render0-dev libxcb-randr0-dev libxcb-composite0-dev libxcb-image0-dev libxcb-present-dev libxcb-xinerama0-dev libxcb-glx0-dev libpixman-1-dev libdbus-1-dev libconfig-dev libgl1-mesa-dev libpcre3-dev libevdev-dev uthash-dev libev-dev libx11-xcb-dev ;; pacman) - sudo pacman -S --needed uthash ninja meson + sudo pacman -S --noconfirm --needed uthash ninja meson ;; esac # build and install picom -intorepo https://github.com/yshui/picom.git "$DIR/repo" +intorepo https://github.com/klesh/picom.git "$DIR/repos/picom" meson --buildtype=release . build sudo ninja -C build install exitrepo -sudo cp -f "$DIR/content/picomdaemon" "$PREFIX/bin" +sudo cp -f "$DIR/picom/picomdaemon" "$PREFIX/bin" sudo chmod +x "$PREFIX/bin/picomdaemon" echo 'picom installed' # configuration -lnsf "$DIR/content/picom.conf" "$XDG_CONFIG_HOME/picom/picom.conf" +lnsf "$DIR/picom/picom.conf" "$XDG_CONFIG_HOME/picom/picom.conf" diff --git a/picom/content/picom.conf b/gui/picom/picom.conf similarity index 100% rename from picom/content/picom.conf rename to gui/picom/picom.conf diff --git a/picom/content/picomdaemon b/gui/picom/picomdaemon similarity index 100% rename from picom/content/picomdaemon rename to gui/picom/picomdaemon diff --git a/player/install.sh b/gui/player.sh similarity index 50% rename from player/install.sh rename to gui/player.sh index 5a2dbe7..87b5131 100755 --- a/player/install.sh +++ b/gui/player.sh @@ -1,8 +1,10 @@ #!/bin/sh +set -e DIR=$(dirname "$(readlink -f "$0")") . "$DIR/../env.sh" +log 'Setting up player: mpv mpd' # install music and video player case "$PM" in @@ -10,16 +12,16 @@ case "$PM" in sudo apt install -y mpd mpc ncmpcpp mpv ;; pacman) - sudo pacman -S --needed mpd mpc ncmpcpp mpv + sudo pacman -S --noconfirm --needed mpd mpc ncmpcpp mpv ;; esac # symlink configuration -lnsf "$DIR/config/mpd/mpd.conf" "$XDG_CONFIG_HOME/mpd/mpd.conf" -lnsf "$DIR/config/mpv/mpv.conf" "$XDG_CONFIG_HOME/mpv/mpv.conf" -lnsf "$DIR/config/mpv/scripts/organize.lua" "$XDG_CONFIG_HOME/mpv/scripts/organize.lua" -lnsf "$DIR/config/ncmpcpp/bindings" "$XDG_CONFIG_HOME/ncmpcpp/bindings" -lnsf "$DIR/config/ncmpcpp/config" "$XDG_CONFIG_HOME/ncmpcpp/config" +lnsf "$DIR/mpd/mpd.conf" "$XDG_CONFIG_HOME/mpd/mpd.conf" +lnsf "$DIR/mpv/mpv.conf" "$XDG_CONFIG_HOME/mpv/mpv.conf" +lnsf "$DIR/mpv/scripts/organize.lua" "$XDG_CONFIG_HOME/mpv/scripts/organize.lua" +lnsf "$DIR/ncmpcpp/bindings" "$XDG_CONFIG_HOME/ncmpcpp/bindings" +lnsf "$DIR/ncmpcpp/config" "$XDG_CONFIG_HOME/ncmpcpp/config" # prevent system-wide mpd sudo systemctl disable mpd diff --git a/optim/pulse-echo-cacnel.sh b/gui/pulse-echo-cacnel.sh similarity index 100% rename from optim/pulse-echo-cacnel.sh rename to gui/pulse-echo-cacnel.sh diff --git a/suckless/install.sh b/gui/suckless.sh similarity index 63% rename from suckless/install.sh rename to gui/suckless.sh index 81805b6..d952a1e 100755 --- a/suckless/install.sh +++ b/gui/suckless.sh @@ -4,34 +4,16 @@ set -e DIR=$(dirname "$(readlink -f "$0")") . "$DIR/../env.sh" -"$PDIR/fish/install.sh" -"$PDIR/gui/install.sh" -"$PDIR/picom/install.sh" -"$PDIR/dunst/install.sh" - +log 'Setting up suckless' # install dependencies case "$PM" in apt) sudo apt install \ - xorg libx11-dev libxft-dev libxinerama-dev libxcursor-dev \ - libxrandr-dev arandr autorandr \ - ibus ibus-table ibus-table-wubi \ - pavucontrol \ - gnome-keyring \ - xss-lock \ - nitrogen \ trayer sudo apt remove gdm3 ;; pacman) - sudo pacman -S --needed \ - xorg-server xorg-xinit xorg-xrandr xorg-xev xorg-xprop \ - alsa-firmware alsa-utils alsa-plugins pulseaudio-alsa pulseaudio pavucontrol \ - arandr autorandr \ - ibus ibus-table ibus-table-chinese \ - gnome-keyring \ - xss-lock \ - nitrogen \ + sudo pacman -S --noconfirm --needed \ trayer ;; esac @@ -47,11 +29,10 @@ installrepo () { installrepo https://gitee.com/klesh/st.git st installrepo https://gitee.com/klesh/dmenu.git dmenu installrepo https://gitee.com/klesh/slock.git slock -installrepo https://github.com/klesh/dict.sh.git dict.sh installrepo https://gitee.com/klesh/dwm.git dwm +installrepo https://github.com/klesh/dict.sh.git dict.sh # config xinit to start for dwm -rm ~/.xinitrc cat < ~/.xinitrc #!/bin/sh @@ -76,7 +57,7 @@ while :; do done EOT -cat <<'EOT' | sed "s/__DIR__/$DIR/g" > ~/.profile +cat <<'EOT' | sed "s|__DIR__|$DIR|g" > ~/.profile #!/bin/sh export PATH=__DIR__/bin:$HOME/.local/bin:$PATH @@ -91,5 +72,5 @@ EOT # config dwm mkdir -p "$XDG_CONFIG_HOME/dwm" -lnsf "$DIR/config/dwm/autostart" "$XDG_CONFIG_HOME/dwm/autostart" -lnsf "$DIR/config/autorandr/postswitch" "$XDG_CONFIG_HOME/autorandr/postswitch" +lnsf "$DIR/dwm/autostart" "$XDG_CONFIG_HOME/dwm/autostart" +lnsf "$DIR/autorandr/postswitch" "$XDG_CONFIG_HOME/autorandr/postswitch" diff --git a/gui/suspendlock.sh b/gui/suspendlock.sh new file mode 100755 index 0000000..c63d736 --- /dev/null +++ b/gui/suspendlock.sh @@ -0,0 +1,22 @@ +#!/bin/sh + +set -e +DIR=$(dirname "$(readlink -f "$0")") +. "$DIR/../env.sh" + +log 'Setting up lock on suspend' + +echo " +[Unit] +Description=Lock on suspend +Before=sleep.target + +[Service] +ExecStart=/usr/bin/loginctl lock-sessions +ExecStartPost=/usr/bin/sleep 2 + +[Install] +WantedBy=sleep.target +" | sudo tee /etc/systemd/system/suspendlock.service >/dev/null + +sudo systemctl enable suspendlock diff --git a/gui/sysutils.sh b/gui/sysutils.sh new file mode 100755 index 0000000..dd9f87c --- /dev/null +++ b/gui/sysutils.sh @@ -0,0 +1,67 @@ +#!/bin/sh + +set -e +DIR=$(dirname "$(readlink -f "$0")") +. "$DIR/../env.sh" + +log 'Setting up system utilities X11 ibus keyring dunst clipboard screenshot thunar network bluetooth' + +case "$PM" in + apt) + sudo apt install -y \ + xorg libx11-dev libxft-dev libxinerama-dev libxcursor-dev \ + libxrandr-dev arandr autorandr \ + pavucontrol \ + ibus ibus-table ibus-table-wubi \ + gnome-keyring \ + xss-lock \ + nitrogen \ + network-manager network-manager-gnome \ + exfat-utils \ + dunst \ + xclip xsel xdotool \ + libnotify-bin \ + flameshot scrot \ + thunar gvfs-bin gvfs-backends thunar-archive-plugin file-roller tumbler + # bluetooth + if has_bluetooth; then + sudo apt install \ + bluez bluez-tools blueman pulseaudio-module-bluetooth + sudo systemctl enable bluetooth + sudo systemctl start bluetooth + fi + ;; + pacman) + # for setting up default programs: exo-preferred-applications + sudo pacman -S --noconfirm --needed \ + xorg-server xorg-xinit xorg-xrandr xorg-xev xorg-xprop \ + arandr autorandr \ + alsa-firmware alsa-utils alsa-plugins pulseaudio-alsa pulseaudio pavucontrol \ + ibus ibus-table ibus-table-chinese \ + gnome-keyring \ + xss-lock \ + nitrogen \ + networkmanager network-manager-applet \ + exfat-utils \ + exo \ + dunst \ + xclip xsel xdotool \ + gnome-keyring libsecret \ + flameshot scrot \ + thunar gvfs-smb gvfs-mtp thunar-archive-plugin file-roller tumbler + # bluetooth + if has_bluetooth; then + sudo pacman -S --noconfirm --needed \ + bluez bluez-utils blueman pulseaudio-bluetooth xorg-xbacklight + sudo systemctl enable bluetooth + sudo systemctl start bluetooth + fi + ;; +esac + +# start network +sudo systemctl enable NetworkManager +sudo systemctl start NetworkManager + +lnsf "$DIR/dunst/dunstrc" "$XDG_CONFIG_HOME/dunst/dunstrc" +lnsf "$DIR/thunar/uca.xml" "$XDG_CONFIG_HOME/Thunar/uca.xml" diff --git a/gui/theme.sh b/gui/theme.sh index 4cd4ca7..33d85c5 100755 --- a/gui/theme.sh +++ b/gui/theme.sh @@ -4,7 +4,8 @@ set -e DIR=$(dirname "$(readlink -f "$0")") . "$DIR/../env.sh" -# for better looking +log 'Setting up theme' + case "$PM" in apt) sudo apt install -y \ @@ -17,7 +18,7 @@ case "$PM" in cd - ;; pacman) - sudo pacman -S --needed \ + sudo pacman -S --noconfirm --needed \ lxappearance arc-gtk-theme arc-icon-theme qt5ct qt5-styleplugins ;; esac diff --git a/thunar/Thunar/uca.xml b/gui/thunar/uca.xml similarity index 100% rename from thunar/Thunar/uca.xml rename to gui/thunar/uca.xml diff --git a/apps/config/zathura/zathurarc b/gui/zathura/zathurarc similarity index 100% rename from apps/config/zathura/zathurarc rename to gui/zathura/zathurarc diff --git a/nodejs/install.sh b/nodejs/install.sh deleted file mode 100755 index a7bbcf9..0000000 --- a/nodejs/install.sh +++ /dev/null @@ -1,59 +0,0 @@ -#!/bin/sh - -DIR=$(dirname "$(readlink -f "$0")") -. "$DIR/../env.sh" - -# install specific version -if [ -n "$1" ]; then - if command -v node 1>/dev/null 2>&1 && [ "$1" != "$(node -v)" ]; then - NODE_URL=https://nodejs.org/dist - in_china && NODE_URL=https://npm.taobao.org/mirrors/node - if [ "$1" = 'ls' ]; then - curl -s $NODE_URL/index.json | jq '.[] | "\(.version) \(if .lts then "(lts)" else "" end)"' -r | less - exit - else - FN=node-$1-linux-x64.tar.gz - wget -O "/tmp/$FN" "$NODE_URL/$1/$FN" - sudo tar zxvf "/tmp/$FN" --strip 1 -C /usr/local/ - rm "/tmp/$FN" - fi - fi -else -# install from distribution repo - case "$PM" in - apt) - sudo apt install -y nodejs npm yarnpkg - ;; - pacman) - sudo pacman -S --needed nodejs npm yarn - ;; - esac -fi - - -# install nvm -if command -v fish 2>/dev/null; then - fish -c "fisher add jorgebucaran/nvm.fish" -else - curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.3/install.sh | bash -fi - - -# config mirrors for CHINA -if in_china; then - sudo npm install cnpm -g --registry=https://r.npm.taobao.org - yarnpkg config set registry https://registry.npm.taobao.org --global && \ - yarnpkg config set disturl https://npm.taobao.org/dist --global && \ - yarnpkg config set sass_binary_site https://npm.taobao.org/mirrors/node-sass --global && \ - yarnpkg config set electron_mirror https://npm.taobao.org/mirrors/electron/ --global && \ - yarnpkg config set puppeteer_download_host https://npm.taobao.org/mirrors --global && \ - yarnpkg config set chromedriver_cdnurl https://npm.taobao.org/mirrors/chromedriver --global && \ - yarnpkg config set operadriver_cdnurl https://npm.taobao.org/mirrors/operadriver --global && \ - yarnpkg config set phantomjs_cdnurl https://npm.taobao.org/mirrors/phantomjs --global && \ - yarnpkg config set selenium_cdnurl https://npm.taobao.org/mirrors/selenium --global && \ - yarnpkg config set sqlite3_binary_host_mirror https://foxgis.oss-cn-shanghai.aliyuncs.com/ --global && \ - yarnpkg config set profiler_binary_host_mirror https://npm.taobao.org/mirrors/node-inspector/ --global && \ - yarnpkg config set chromedriver_cdnurl https://cdn.npm.taobao.org/dist/chromedriver --global && \ - yarnpkg config set node_inspector_cdnurl https://npm.taobao.org/mirrors/node-inspector --global && \ - yarnpkg config set sentrycli_cdnurl https://npm.taobao.org/mirrors/sentry-cli -fi diff --git a/nvim/install.sh b/nvim/install.sh deleted file mode 100755 index 781edbb..0000000 --- a/nvim/install.sh +++ /dev/null @@ -1,28 +0,0 @@ -#!/bin/sh - -DIR=$(dirname "$(readlink -f "$0")") -. "$DIR/../env.sh" - -# check dependencies -! command -v yarnpkg && "$PDIR/nodejs/install.sh" -! command -v pip && "$PDIR/python/install.sh" - -# install nvim -case "$PM" in - apt) - sudo add-apt-repository ppa:neovim-ppa/stable -y - sudo apt update - sudo apt install -y neovim - sudo pip3 install pyvim neovim - ;; - pacman) - sudo pacman -S --needed neovim - sudo pip install pyvim neovim - ;; -esac - -# symlink configuration -lnsf "$DIR/config/init.vim" "$XDG_CONFIG_HOME/nvim/init.vim" -lnsf "$DIR/config/coc-settings.json" "$XDG_CONFIG_HOME/nvim/coc-settings.json" -lnsf "$DIR/config/init.vim" ~/.vimrc -lnsf "$DIR/config/coc-settings.json" ~/.vim/coc-settings.json diff --git a/optim/mirrors.sh b/optim/mirrors.sh deleted file mode 100755 index 783c2f6..0000000 --- a/optim/mirrors.sh +++ /dev/null @@ -1,25 +0,0 @@ -#!/bin/sh - -DIR=$(dirname "$(readlink -f "$0")") -. "$DIR/../env.sh" - - -! in_china && echo 'Skip mirrors configuration' && exit - -# setup package mirror for CHINA -case "$PM" in - apt) - # backup original sources.list - [ ! -f /etc/apt/sources.list.bak ] && \ - sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak - # replace with aliyun mirror - awk '$0 ~ /^deb/ {$2="https://mirrors.aliyun.com/ubuntu/"; print}' /etc/apt/sources.list.bak | sudo tee /etc/apt/sources.list - sudo apt update - ;; - pacman) - echo TODO - exit 1 - ;; -esac - - diff --git a/optim/ubuntu-desk-boot.sh b/optim/ubuntu-desk-boot.sh deleted file mode 100755 index 61156e8..0000000 --- a/optim/ubuntu-desk-boot.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/sh - - -sudo systemctl disable systemd-networkd-wait-online -sudo systemctl mask systemd-networkd-wait-online -sudo systemctl disable cloud-init -sudo systemctl mask cloud-init -sudo systemctl disable cloud-config -sudo systemctl mask cloud-config -sudo systemctl disable gdm3 -sudo systemctl mask gdm3 diff --git a/python/install.sh b/python/install.sh deleted file mode 100755 index 89c3a56..0000000 --- a/python/install.sh +++ /dev/null @@ -1,32 +0,0 @@ -#!/bin/sh - -DIR=$(dirname "$(readlink -f "$0")") -. "$DIR/../env.sh" - -# config pip mirror for CHINA -if in_china; then - lnsf "$DIR/pip.conf" ~/.pip/pip.conf - if sudo [ ! -f /root/.pip/pip.conf ]; then - sudo mkdir -p /root/.pip - sudo cp "$DIR/pip.conf" /root/.pip/pip.conf - fi - sudo mkdir -p /root/.pip - sudo cp python/pip.conf /root/.pip/pip.conf -fi - -# install python3 -case "$PM" in - apt) - sudo apt install python3 python3-pip python-is-python3 - command -v fish 2>/dev/null && sudo pip3 install virtualfish - ;; - pacman) - sudo pacman -S --needed python python-pip - command -v fish 2>/dev/null && sudo pip install virtualfish - ;; -esac - -# enable auto_activation plugin for virtualfish -command -v fish 2>/dev/null && fish -c "yes | vf install && vf addplugins auto_activation" - - diff --git a/python/pip.conf b/python/pip.conf deleted file mode 100644 index da741b7..0000000 --- a/python/pip.conf +++ /dev/null @@ -1,3 +0,0 @@ -[global] -index-url = https://mirrors.aliyun.com/pypi/simple -#index-url = https://pypi.doubanio.com/simple diff --git a/python/py3.sh b/python/py3.sh deleted file mode 100755 index efb3173..0000000 --- a/python/py3.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/sh - -set -e - -# install python3.8 -sudo add-apt-repository ppa:deadsnakes/ppa -sudo apt-get update -sudo apt-get install python3.8 - -# install pip and other distutils -sudo apt install python3.8-distutils -sudo python3.8 -m pip install --upgrade pip setuptools wheel diff --git a/ranger/install.sh b/ranger/install.sh deleted file mode 100755 index 692afdb..0000000 --- a/ranger/install.sh +++ /dev/null @@ -1,29 +0,0 @@ -#!/bin/sh - -set -e -DIR=$(dirname "$(readlink -f "$0")") -. "$DIR/../env.sh" - -# install ranger -case "$PM" in - apt) - # atool/p7zip-full for archive previewing/extracting etc - sudo apt install -y atool p7zip-full unrar highlight - ! command -v pip3 && "$PDIR/python/install.sh" - sudo pip3 install ranger-fm ueberzug - ;; - pacman) - sudo pacman -S --needed atool p7zip unrar highlight - sudo pip install ranger-fm ueberzug - ;; -esac - -# linking configuration files -lnsf "$DIR/config/commands.py" "$XDG_CONFIG_HOME/ranger/commands.py" -lnsf "$DIR/config/rc.conf" "$XDG_CONFIG_HOME/ranger/rc.conf" -lnsf "$DIR/config/scope.sh" "$XDG_CONFIG_HOME/ranger/scope.sh" -lnsf "$DIR/config/colorschemes/solarizedmod.py" "$XDG_CONFIG_HOME/ranger/colorschemes/solarizedmod.py" - -# install devicons -[ ! -d ~/.config/ranger/plugins/ranger_devicons ] && \ - git clone --depth 1 https://github.com/alexanderjeurissen/ranger_devicons ~/.config/ranger/plugins/ranger_devicons diff --git a/thunar/install.sh b/thunar/install.sh deleted file mode 100755 index 5b5cda2..0000000 --- a/thunar/install.sh +++ /dev/null @@ -1,19 +0,0 @@ -#!/bin/sh - -DIR=$(dirname "$(readlink -f "$0")") -. "$DIR/../env.sh" - -# install ranger -case "$PM" in - apt) - sudo apt install -y \ - thunar gvfs-bin gvfs-backends thunar-archive-plugin file-roller tumbler - ;; - pacman) - sudo pacman -S --needed \ - thunar gvfs-smb gvfs-mtp thunar-archive-plugin file-roller tumbler - ;; -esac - -# symlink configuration -lnsf "$DIR/Thunar/uca.xml" "$XDG_CONFIG_HOME/Thunar/uca.xml"