From 7b160826f6246c1cd9ac8110cdc66f1e8792f5ae Mon Sep 17 00:00:00 2001 From: Klesh Wong Date: Mon, 9 Nov 2020 00:26:14 +0800 Subject: [PATCH] [misc] refactory --- .gitignore | 2 + README.md | 13 +- apps/docker-arm.sh | 2 +- apps/docker.sh | 2 +- apps/install.sh | 2 +- apps/k8s.sh | 2 +- apps/keepassxc.sh | 2 +- apps/nextcloud.sh | 2 +- autologin/install.sh | 2 +- bak/config/polybar/launch.sh | 0 bak/config/sxhkd/launch.sh | 0 bin/br | 40 +++--- bin/fr | 74 ++++++++++ deeplearning/install.sh | 2 +- .../{config/launch.sh => content/dunstdaemon} | 4 +- dunst/{config => content}/dunstrc | 0 dunst/install.sh | 7 +- env.sh | 23 ++- fish/install.sh | 2 +- gui/freetype2.sh | 0 gui/install.sh | 2 +- gui/sshd.sh | 2 +- gui/theme.sh | 2 +- gui/updatenerdfonticons.sh | 2 +- kvm/install.sh | 2 +- nodejs/install.sh | 2 +- nvim/install.sh | 2 +- optim/bbr.sh | 0 optim/mirrors.sh | 2 +- optim/ubuntu-desk-boot.sh | 0 picom/config/launch.sh | 11 -- picom/config/toggle.sh | 9 -- picom/{config => content}/picom.conf | 0 picom/content/picomdaemon | 36 +++++ picom/install.sh | 31 ++-- player/install.sh | 2 +- python/install.sh | 2 +- python/py3.sh | 0 ranger/config/scope.sh | 0 ranger/install.sh | 2 +- suckless/config/dwm/autostart | 6 +- suckless/config/dwm/statusbar | 135 ------------------ suckless/install.sh | 37 ++--- thunar/install.sh | 2 +- tmux/install.sh | 2 +- win/wsl.sh | 0 46 files changed, 227 insertions(+), 245 deletions(-) mode change 100755 => 100644 apps/docker-arm.sh mode change 100755 => 100644 apps/docker.sh mode change 100755 => 100644 apps/install.sh mode change 100755 => 100644 apps/k8s.sh mode change 100755 => 100644 apps/keepassxc.sh mode change 100755 => 100644 apps/nextcloud.sh mode change 100755 => 100644 autologin/install.sh mode change 100755 => 100644 bak/config/polybar/launch.sh mode change 100755 => 100644 bak/config/sxhkd/launch.sh create mode 100755 bin/fr mode change 100755 => 100644 deeplearning/install.sh rename dunst/{config/launch.sh => content/dunstdaemon} (55%) rename dunst/{config => content}/dunstrc (100%) mode change 100755 => 100644 dunst/install.sh mode change 100755 => 100644 env.sh mode change 100755 => 100644 fish/install.sh mode change 100755 => 100644 gui/freetype2.sh mode change 100755 => 100644 gui/install.sh mode change 100755 => 100644 gui/sshd.sh mode change 100755 => 100644 gui/theme.sh mode change 100755 => 100644 gui/updatenerdfonticons.sh mode change 100755 => 100644 kvm/install.sh mode change 100755 => 100644 nodejs/install.sh mode change 100755 => 100644 nvim/install.sh mode change 100755 => 100644 optim/bbr.sh mode change 100755 => 100644 optim/mirrors.sh mode change 100755 => 100644 optim/ubuntu-desk-boot.sh delete mode 100755 picom/config/launch.sh delete mode 100755 picom/config/toggle.sh rename picom/{config => content}/picom.conf (100%) create mode 100755 picom/content/picomdaemon mode change 100755 => 100644 picom/install.sh mode change 100755 => 100644 player/install.sh mode change 100755 => 100644 python/install.sh mode change 100755 => 100644 python/py3.sh mode change 100755 => 100644 ranger/config/scope.sh mode change 100755 => 100644 ranger/install.sh delete mode 100755 suckless/config/dwm/statusbar mode change 100755 => 100644 suckless/install.sh mode change 100755 => 100644 thunar/install.sh mode change 100755 => 100644 tmux/install.sh mode change 100755 => 100644 win/wsl.sh diff --git a/.gitignore b/.gitignore index 116d9d8..53689c9 100644 --- a/.gitignore +++ b/.gitignore @@ -11,3 +11,5 @@ Thunar/config/accels.scm nvim/config/autoload nvim/config/plugged nvim/config/.* +repos/ +repo/ diff --git a/README.md b/README.md index 30404ce..2a5df9d 100644 --- a/README.md +++ b/README.md @@ -1 +1,12 @@ -TODO \ No newline at end of file +TODO +# dotfiles + + * openurl copy move to dmenu + * auto install dict.sh + + +# How to use + +1. fork this repo +2. run installation script base on your need +3. customize to your taste and sync to your own repo diff --git a/apps/docker-arm.sh b/apps/docker-arm.sh old mode 100755 new mode 100644 index 58e8ce8..5de3f0c --- a/apps/docker-arm.sh +++ b/apps/docker-arm.sh @@ -1,7 +1,7 @@ #!/bin/sh set -e -DIR=$(readlink -f "$(dirname "$0")") +DIR=$(dirname "$(readlink -f "$0")") . "$DIR/../env.sh" diff --git a/apps/docker.sh b/apps/docker.sh old mode 100755 new mode 100644 index c5101b8..4b2c5c6 --- a/apps/docker.sh +++ b/apps/docker.sh @@ -1,6 +1,6 @@ #!/bin/sh -DIR=$(readlink -f "$(dirname "$0")") +DIR=$(dirname "$(readlink -f "$0")") . "$DIR/../env.sh" diff --git a/apps/install.sh b/apps/install.sh old mode 100755 new mode 100644 index 81a3202..db0880e --- a/apps/install.sh +++ b/apps/install.sh @@ -1,6 +1,6 @@ #!/bin/sh -DIR=$(readlink -f "$(dirname "$0")") +DIR=$(dirname "$(readlink -f "$0")") . "$DIR/../env.sh" diff --git a/apps/k8s.sh b/apps/k8s.sh old mode 100755 new mode 100644 index ad837cb..7844486 --- a/apps/k8s.sh +++ b/apps/k8s.sh @@ -1,6 +1,6 @@ #!/bin/sh -DIR=$(readlink -f "$(dirname "$0")") +DIR=$(dirname "$(readlink -f "$0")") . "$DIR/../env.sh" diff --git a/apps/keepassxc.sh b/apps/keepassxc.sh old mode 100755 new mode 100644 index 9ba109e..e0ef45e --- a/apps/keepassxc.sh +++ b/apps/keepassxc.sh @@ -1,6 +1,6 @@ #!/bin/sh -DIR=$(readlink -f "$(dirname "$0")") +DIR=$(dirname "$(readlink -f "$0")") . "$DIR/../env.sh" diff --git a/apps/nextcloud.sh b/apps/nextcloud.sh old mode 100755 new mode 100644 index d49175d..3046882 --- a/apps/nextcloud.sh +++ b/apps/nextcloud.sh @@ -1,6 +1,6 @@ #!/bin/sh -DIR=$(readlink -f "$(dirname "$0")") +DIR=$(dirname "$(readlink -f "$0")") . "$DIR/../env.sh" diff --git a/autologin/install.sh b/autologin/install.sh old mode 100755 new mode 100644 index 1ca1209..6ed6c12 --- a/autologin/install.sh +++ b/autologin/install.sh @@ -1,6 +1,6 @@ #!/bin/sh -DIR=$(readlink -f "$(dirname "$0")") +DIR=$(dirname "$(readlink -f "$0")") . "$DIR/../env.sh" echo 'Please enter autologin username (empty to skip): ' diff --git a/bak/config/polybar/launch.sh b/bak/config/polybar/launch.sh old mode 100755 new mode 100644 diff --git a/bak/config/sxhkd/launch.sh b/bak/config/sxhkd/launch.sh old mode 100755 new mode 100644 diff --git a/bin/br b/bin/br index 6d9ed73..d4e9969 100755 --- a/bin/br +++ b/bin/br @@ -1,21 +1,25 @@ #!/bin/sh -if [ "$#" -lt 2 ]; then - echo "Usage: $0 " - exit 1 +# rule 1: use single quote ' +# rule 2: //// for literal / + +set -e +FILES=$(awk '{print}') +COL=$(tput cols) +PAT=$1 +STR=$2 +export COL PAT STR + +echo "$FILES" | while IFS= read -r FILE; do + bin/fr "$FILE" +done | less + +printf "Are you sure [y/N]? " +read -r YN < /dev/tty +if [ "$YN" = 'y' ]; then + echo "$FILES" | while IFS= read -r FILE; do + TMP=$(mktemp) + REP=1 bin/fr "$FILE" > "$TMP" + mv "$TMP" "$FILE" + done fi - -REDFG=$(printf '\033[31m') -BLUBG=$(printf '\033[42m') -ag --color "$1" . | sed -E "s/$1/\\0$REDFG$BLUBG$2/g" -echo Are they ok for you? -read -r YN - -case "$YN" in - y|Y) - ag "$1" . -l -0 | xargs -0 sed -Ei "s/$1/$2/g" - ;; - *) - exit - ;; -esac diff --git a/bin/fr b/bin/fr new file mode 100755 index 0000000..c9e79ea --- /dev/null +++ b/bin/fr @@ -0,0 +1,74 @@ +#!/bin/gawk -f + +BEGIN { + PAT = "(" ENVIRON["PAT"] ")" + STR = ENVIRON["STR"] + REP = ENVIRON["REP"] + COL = ENVIRON["COL"] + OLD = "\033[31m" + NEW = "\033[32m" + LNN = "\033[30m\033[47m" + LNH = "\033[30m\033[41m" + RST = "\033[0m" + CTX = 2 + #print "PAT:" PAT + #print "STR:" STR +} + +function min(a, b) { + return a > b ? b : a +} + +function fileend() { + if (REP) exit + split(buffer, lines, "\n") + if (!length(lines)) exit + printf "\033[42m\033[30m%s%" COL-length(filename) "s\033[0m\n", filename, " " + pad = length(length(lines) - 1) + for (i in lines) { + if (!match(lines[i], /([[:digit:]]+)(:|-)(.*)$/, m)) + continue + linno = m[1] + found = m[2] == ":" + line = m[3] + print (found ? LNH : LNN) sprintf(" %"pad"d ", linno) RST line + } +} + + +!REP && FNR == 1 { + if (buffer) fileend() + filename = FILENAME + delete before + buffer = "" + printed = 0 +} + +!REP { + delete data + line = gensub(PAT, OLD "\\1" NEW STR RST, "g", $0) + found = index(line, OLD) + fmted = FNR (found ? ":" : "-") line + if (found) { + for (i = min(FNR-printed-1, CTX); i > 0; i--) { + if (before[i]) buffer = buffer "\n" before[i] + } + buffer = buffer "\n" fmted + printed = FNR + keep = CTX + } else if (keep-- > 0) { + buffer = buffer "\n" fmted + printed = FNR + } + + for (i = CTX; i > 1; i--) { + before[i] = before[i - 1] + } + before[1] = fmted +} + +END { fileend() } + +REP { + print gensub(PAT, STR, "g", $0) +} diff --git a/deeplearning/install.sh b/deeplearning/install.sh old mode 100755 new mode 100644 index 1783032..d96e1c9 --- a/deeplearning/install.sh +++ b/deeplearning/install.sh @@ -1,6 +1,6 @@ #!/bin/sh -DIR=$(readlink -f "$(dirname "$0")") +DIR=$(dirname "$(readlink -f "$0")") . "$DIR/../env.sh" diff --git a/dunst/config/launch.sh b/dunst/content/dunstdaemon similarity index 55% rename from dunst/config/launch.sh rename to dunst/content/dunstdaemon index 8ef79d2..0089a96 100755 --- a/dunst/config/launch.sh +++ b/dunst/content/dunstdaemon @@ -1,7 +1,5 @@ #!/bin/sh -DIR=$(readlink -f $(dirname $0)) - killall -q dunst while pgrep -x dunst >/dev/null; do sleep 1; done -dunst -config $DIR/dunstrc & +dunst & diff --git a/dunst/config/dunstrc b/dunst/content/dunstrc similarity index 100% rename from dunst/config/dunstrc rename to dunst/content/dunstrc diff --git a/dunst/install.sh b/dunst/install.sh old mode 100755 new mode 100644 index 30378b4..546837b --- a/dunst/install.sh +++ b/dunst/install.sh @@ -1,6 +1,6 @@ #!/bin/sh -DIR=$(readlink -f "$(dirname "$0")") +DIR=$(dirname "$(readlink -f "$0")") . "$DIR/../env.sh" # install nvim @@ -14,5 +14,6 @@ case "$PM" in esac # symlink configuration -lnsf "$DIR/config/dunstrc" "$XDG_CONFIG_HOME/dunst/dunstrc" -lnsf "$DIR/config/launch.sh" "$XDG_CONFIG_HOME/dunst/launch.sh" +lnsf "$DIR/content/dunstrc" "$XDG_CONFIG_HOME/dunst/dunstrc" +sudo cp -f "$DIR/content/dunstctl" "$PREFIX/bin" +sudo chmod +x "$PREFIX/bin/dunstctl" diff --git a/env.sh b/env.sh old mode 100755 new mode 100644 index 209c6dc..fe5870f --- a/env.sh +++ b/env.sh @@ -3,9 +3,14 @@ set -e 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 @@ -31,7 +36,7 @@ in_china () { lnsf () { [ "$#" -ne 2 ] && echo "lnsf " && return 1 - TARGET=$(readlink -f "$1") + TARGET=$(readlink -f "$1") || echo failed: readlink -f "$1" && return 1 SYMLNK=$2 [ -z "$TARGET" ] && echo "$1 not exists" && return 1 SYMDIR=$(dirname "$SYMLNK") @@ -55,6 +60,22 @@ eqv () { [ "$VERSION" = "$VERSION2" ] } +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 +} + +exitrepo() { + cd "$ODIR" +} + # install basic common utilities case "$PM" in diff --git a/fish/install.sh b/fish/install.sh old mode 100755 new mode 100644 index a18ca84..d0581f4 --- a/fish/install.sh +++ b/fish/install.sh @@ -1,6 +1,6 @@ #!/bin/sh -DIR=$(readlink -f "$(dirname "$0")") +DIR=$(dirname "$(readlink -f "$0")") . "$DIR/../env.sh" # install fish shell diff --git a/gui/freetype2.sh b/gui/freetype2.sh old mode 100755 new mode 100644 diff --git a/gui/install.sh b/gui/install.sh old mode 100755 new mode 100644 index 6feee08..ef66b9d --- a/gui/install.sh +++ b/gui/install.sh @@ -1,6 +1,6 @@ #!/bin/sh -DIR=$(readlink -f "$(dirname "$0")") +DIR=$(dirname "$(readlink -f "$0")") . "$DIR/../env.sh" # install basic gui stuff, including fonts/system utilties/keyring etc diff --git a/gui/sshd.sh b/gui/sshd.sh old mode 100755 new mode 100644 index f88b756..7335a53 --- a/gui/sshd.sh +++ b/gui/sshd.sh @@ -1,6 +1,6 @@ #!/bin/sh -DIR=$(readlink -f "$(dirname "$0")") +DIR=$(dirname "$(readlink -f "$0")") . "$DIR/../env.sh" # install sshd diff --git a/gui/theme.sh b/gui/theme.sh old mode 100755 new mode 100644 index 0d96a00..4cd4ca7 --- a/gui/theme.sh +++ b/gui/theme.sh @@ -1,7 +1,7 @@ #!/bin/sh set -e -DIR=$(readlink -f "$(dirname "$0")") +DIR=$(dirname "$(readlink -f "$0")") . "$DIR/../env.sh" # for better looking diff --git a/gui/updatenerdfonticons.sh b/gui/updatenerdfonticons.sh old mode 100755 new mode 100644 index 6d05aaf..15eb0bc --- a/gui/updatenerdfonticons.sh +++ b/gui/updatenerdfonticons.sh @@ -1,6 +1,6 @@ #!/bin/sh -DIR=$(readlink -f "$(dirname "$0")") +DIR=$(dirname "$(readlink -f "$0")") . "$DIR/../env.sh" [ -z "$1" ] && echo Usage: $0 path/to/nerdfont.git/bin/scrips/lib && exit 1 diff --git a/kvm/install.sh b/kvm/install.sh old mode 100755 new mode 100644 index 2ece8e7..1fb8785 --- a/kvm/install.sh +++ b/kvm/install.sh @@ -1,6 +1,6 @@ #!/bin/sh -DIR=$(readlink -f "$(dirname "$0")") +DIR=$(dirname "$(readlink -f "$0")") . "$DIR/../env.sh" # tips diff --git a/nodejs/install.sh b/nodejs/install.sh old mode 100755 new mode 100644 index 0994c5d..a7bbcf9 --- a/nodejs/install.sh +++ b/nodejs/install.sh @@ -1,6 +1,6 @@ #!/bin/sh -DIR=$(readlink -f "$(dirname "$0")") +DIR=$(dirname "$(readlink -f "$0")") . "$DIR/../env.sh" # install specific version diff --git a/nvim/install.sh b/nvim/install.sh old mode 100755 new mode 100644 index b90b5e6..781edbb --- a/nvim/install.sh +++ b/nvim/install.sh @@ -1,6 +1,6 @@ #!/bin/sh -DIR=$(readlink -f "$(dirname "$0")") +DIR=$(dirname "$(readlink -f "$0")") . "$DIR/../env.sh" # check dependencies diff --git a/optim/bbr.sh b/optim/bbr.sh old mode 100755 new mode 100644 diff --git a/optim/mirrors.sh b/optim/mirrors.sh old mode 100755 new mode 100644 index bb116ae..783c2f6 --- a/optim/mirrors.sh +++ b/optim/mirrors.sh @@ -1,6 +1,6 @@ #!/bin/sh -DIR=$(readlink -f "$(dirname "$0")") +DIR=$(dirname "$(readlink -f "$0")") . "$DIR/../env.sh" diff --git a/optim/ubuntu-desk-boot.sh b/optim/ubuntu-desk-boot.sh old mode 100755 new mode 100644 diff --git a/picom/config/launch.sh b/picom/config/launch.sh deleted file mode 100755 index b148942..0000000 --- a/picom/config/launch.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/sh - -DIR=$(readlink -f $(dirname $0)) - -killall -q picom -while pgrep -x picom >/dev/null; do sleep 1; done -picom -b --config $DIR/picom.conf --experimental-backends \ - --blur-method dual_kawase --blur-strength 6 \ - --no-fading-openclose -sleep 1 -! pgrep -x picom && picom -b --config $DIR/picom.conf --no-fading-openclose diff --git a/picom/config/toggle.sh b/picom/config/toggle.sh deleted file mode 100755 index dcbaae9..0000000 --- a/picom/config/toggle.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/sh - -DIR=$(readlink -f $(dirname $0)) - -if pgrep -x picom > /dev/null; then - killall -q picom -else - $DIR/launch.sh -fi diff --git a/picom/config/picom.conf b/picom/content/picom.conf similarity index 100% rename from picom/config/picom.conf rename to picom/content/picom.conf diff --git a/picom/content/picomdaemon b/picom/content/picomdaemon new file mode 100755 index 0000000..1401192 --- /dev/null +++ b/picom/content/picomdaemon @@ -0,0 +1,36 @@ +#!/bin/sh + +set -e + +stop() { + echo stop + killall -q picom || true + while pgrep -x picom >/dev/null; do sleep 1; done +} + +start() { + echo start + picom -b --experimental-backends \ + --blur-method dual_kawase --blur-strength 6 \ + --no-fading-openclose + sleep 1 + ! pgrep -x picom >/dev/null && echo 'fallback' && picom -b --no-fading-openclose +} + +toggle() { + if pgrep -x picom > /dev/null; then + stop + else + start + fi +} + +case $1 in + toggle) + toggle + ;; + *) + stop + start + ;; +esac diff --git a/picom/install.sh b/picom/install.sh old mode 100755 new mode 100644 index 74834eb..3fec352 --- a/picom/install.sh +++ b/picom/install.sh @@ -1,11 +1,11 @@ #!/bin/sh set -e -DIR=$(readlink -f "$(dirname "$0")") +DIR=$(dirname "$(readlink -f "$0")") . "$DIR/../env.sh" -# install ranger +# install dpes case "$PM" in apt) # install build tools @@ -20,24 +20,13 @@ case "$PM" in esac # build and install picom -VERSION=next -VERSION_PATH=$XDG_CONFIG_HOME/picom/version -if [ "$VERSION" = "next" ] || ! eqv "$VERSION_PATH" "$VERSION"; then - echo Downloading picom $VERSION - [ ! -f /tmp/picom-$VERSION.zip ] && \ - curl "https://github.com/yshui/picom/archive/$VERSION.zip" -Lo /tmp/picom-$VERSION.zip - unzip /tmp/picom-$VERSION.zip -d /tmp - FD=$(unzip -l /tmp/picom-$VERSION.zip | awk 'NR==5{print $4}') - cd "/tmp/$FD" - meson --buildtype=release . build - sudo ninja -C build install - cd - - mkdir -p "$(dirname "$VERSION_PATH")" - echo "$VERSION" > "$VERSION_PATH" - sudo rm -rf /tmp/picom-$VERSION* -fi +intorepo https://github.com/yshui/picom.git "$DIR/repo" +meson --buildtype=release . build +sudo ninja -C build install +exitrepo +sudo cp -f "$DIR/content/picomdaemon" "$PREFIX/bin" +sudo chmod +x "$PREFIX/bin/picomdaemon" +echo 'picom installed' # configuration -lnsf "$DIR/config/launch.sh" "$XDG_CONFIG_HOME/picom/launch.sh" -lnsf "$DIR/config/toggle.sh" "$XDG_CONFIG_HOME/picom/toggle.sh" -lnsf "$DIR/config/picom.conf" "$XDG_CONFIG_HOME/picom/picom.conf" +lnsf "$DIR/content/picom.conf" "$XDG_CONFIG_HOME/picom/picom.conf" diff --git a/player/install.sh b/player/install.sh old mode 100755 new mode 100644 index 80a80c0..5a2dbe7 --- a/player/install.sh +++ b/player/install.sh @@ -1,6 +1,6 @@ #!/bin/sh -DIR=$(readlink -f "$(dirname "$0")") +DIR=$(dirname "$(readlink -f "$0")") . "$DIR/../env.sh" diff --git a/python/install.sh b/python/install.sh old mode 100755 new mode 100644 index b1987fb..89c3a56 --- a/python/install.sh +++ b/python/install.sh @@ -1,6 +1,6 @@ #!/bin/sh -DIR=$(readlink -f "$(dirname "$0")") +DIR=$(dirname "$(readlink -f "$0")") . "$DIR/../env.sh" # config pip mirror for CHINA diff --git a/python/py3.sh b/python/py3.sh old mode 100755 new mode 100644 diff --git a/ranger/config/scope.sh b/ranger/config/scope.sh old mode 100755 new mode 100644 diff --git a/ranger/install.sh b/ranger/install.sh old mode 100755 new mode 100644 index acd3c71..692afdb --- a/ranger/install.sh +++ b/ranger/install.sh @@ -1,7 +1,7 @@ #!/bin/sh set -e -DIR=$(readlink -f "$(dirname "$0")") +DIR=$(dirname "$(readlink -f "$0")") . "$DIR/../env.sh" # install ranger diff --git a/suckless/config/dwm/autostart b/suckless/config/dwm/autostart index 7d9dac3..698ad69 100755 --- a/suckless/config/dwm/autostart +++ b/suckless/config/dwm/autostart @@ -1,13 +1,13 @@ #!/bin/sh # start compositor daemon -"$HOME/.config/picom/launch.sh" +picomdaemon # start desktop notification daemon -"$HOME/.config/dunst/launch.sh" +dunstdaemon # start dwmbar daemon -"$HOME/.config/dwm/statusbar" +statusbar # disable screen saver / turn off monitor if inactived for 300 secs xset s off diff --git a/suckless/config/dwm/statusbar b/suckless/config/dwm/statusbar deleted file mode 100755 index fc54697..0000000 --- a/suckless/config/dwm/statusbar +++ /dev/null @@ -1,135 +0,0 @@ -#!/bin/sh - -# symbola -#export ICON_RCD=šŸŽ„ -#export ICON_MSC=ā™¬ -#export ICON_MTD=šŸ”‰ -#export ICON_VOL=šŸ”Š -#export ICON_NIC=šŸ–§ -#export ICON_WFI=šŸ“” -#export ICON_MEM=šŸ“ˆ -#export ICON_TMP=šŸŒ” -#export ICON_PLG=šŸ”Œ -#export ICON_BAT=šŸ”‹ -#export ICON_DAT=ā² - -# nerdfont -export ICON_RCD='ļ©¦' -export ICON_MSC='ļ¢†' -export ICON_MTD='ļ± ' -export ICON_VOL='ļ’… ' -export ICON_NIC='ļ›æ ' -export ICON_WFI='ļ‡« ' -export ICON_MEM='ļ‹› ' -export ICON_TMP='ļ‹‰' -export ICON_PLG='ļ‡¦ ' -export ICON_BA0='ļ‰„ ' -export ICON_BA1='ļ‰ƒ ' -export ICON_BA2='ļ‰‚ ' -export ICON_BA3='ļ‰ ' -export ICON_BA4='ļ‰€ ' -export ICON_DAT='ļ€— ' - -MPD=$(which mpc && echo yes) - -statusbar() { - - echo -n " " - - # recording - [ -f /tmp/recording.pid ] && echo -n "$ICON_RCD " - - # mpd - [ -n "$MPD" ] && mpc | awk ' - NR == 1 { - SONG = $0 - } - NR == 2 { - PLAYING = $1 - } - END { - if (PLAYING == "[playing]") - printf "%s %s ", ENVIRON["ICON_MSC"], SONG - } - ' - - # volume - amixer get Master | awk 'END { - ICO = $NF == "[off]" ? ENVIRON["ICON_MTD"] : ENVIRON["ICON_VOL"] - match($0, / \[([0-9]+%)\] /, m) - VOL = m[1] - printf "%s %s ", ICO, VOL - }' - - # network - for NIC in /sys/class/net/e*; do - grep -q 'up' $NIC/operstate && awk '{ - printf "%s %s ",ENVIRON["ICON_NIC"],($0 >= 1000 ? $0 / 1000 "G" : $0 "M") - }' $NIC/speed - done - - # wifi - awk 'NR > 2 { - printf "%s %i%% ", ENVIRON["ICON_WFI"], $3*100/70 - }' /proc/net/wireless - - # cpu temperature - awk '{ - printf "%s %iĀ°C ", ENVIRON["ICON_TMP"], $0/1000 - }' /sys/class/thermal/thermal_zone0/temp - - # memory usage - free | awk 'NR == 2 { - printf "%s %i%% ", ENVIRON["ICON_MEM"], $3/$2*100 - }' - - # battery - if [ -f /sys/class/power_supply/BAT0/capacity ]; then - grep -q '1' /sys/class/power_supply/AC/online && export PLUGGED=yes - awk '{ - if (ENVIRON["PLUGGED"] == "yes") - ICON=ENVIRON["ICON_PLG"] - else if ($0 > 90) - ICON=ENVIRON["ICON_BA4"] - else if ($0 > 75) - ICON=ENVIRON["ICON_BA3"] - else if ($0 > 50) - ICON=ENVIRON["ICON_BA2"] - else if ($0 > 25) - ICON=ENVIRON["ICON_BA1"] - else - ICON=ENVIRON["ICON_BA0"] - printf "%s %s%% ", ICON, $0 - }' /sys/class/power_supply/BAT0/capacity - fi - - # datetime - echo -n "$ICON_DAT $(date +'%m-%d %H:%M %a') " -} - - -start() { - while :; do - ! pgrep slock 1>/dev/null && xsetroot -name "$(statusbar)" - sleep 1 - done -} - -restart() { - FP=$(readlink -f $0) - pkill -f "$FP loop" - $FP loop & -} - -case "$1" in - loop) - start - ;; - dryrun) - statusbar - ;; - *) - restart - ;; -esac - diff --git a/suckless/install.sh b/suckless/install.sh old mode 100755 new mode 100644 index f3ba1e8..c26d329 --- a/suckless/install.sh +++ b/suckless/install.sh @@ -1,6 +1,7 @@ #!/bin/sh -DIR=$(readlink -f "$(dirname "$0")") +set -e +DIR=$(dirname "$(readlink -f "$0")") . "$DIR/../env.sh" "$PDIR/fish/install.sh" @@ -36,19 +37,23 @@ case "$PM" in esac # clone / compile utilities and dwm itself -mkdir -p ~/Projects/suckless +REPOS="$DIR/suckless/repos" +mkdir -p "$REPOS" -[ ! -d ~/Projects/suckless/st ] && git clone https://gitee.com/klesh/st.git ~/Projects/suckless/st -cd ~/Projects/suckless/st && sudo rm -f config.h && sudo make clean install +installrepo () { + ODIR=$(pwd) + REPO="$DIR/suckless/repos/$2" + [ ! -d "$REPO" ] && git clone --depth "$1" "$REPO" + cd "$REPO" + make && sudo make install + cd "$ODIR" +} -[ ! -d ~/Projects/suckless/dmenu ] &&git clone https://gitee.com/klesh/dmenu.git ~/Projects/suckless/dmenu -cd ~/Projects/suckless/dmenu && sudo rm -f config.h && sudo make clean install - -[ ! -d ~/Projects/suckless/slock ] &&git clone https://gitee.com/klesh/slock.git ~/Projects/suckless/slock -cd ~/Projects/suckless/slock && sudo rm -f config.h && sudo make clean install - -[ ! -d ~/Projects/suckless/dwm ] &&git clone https://gitee.com/klesh/dwm.git ~/Projects/suckless/dwm -cd ~/Projects/suckless/dwm && sudo rm -f config.h && sudo make clean install +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 # config xinit to start for dwm rm ~/.xinitrc @@ -70,14 +75,10 @@ export SSH_AUTH_SOCK=$(/usr/bin/gnome-keyring-daemon --start --components=pkcs11 autorandr --change --force # restart dwm if it existed without error -echo $$(date "+%Y%m%d-%H%M%S") '=============== xrdb -query' >> /tmp/xinit.log -xrdb -query >> /tmp/dwm.log -echo $$(date "+%Y%m%d-%H%M%S") '=============== enter dwm' >> /tmp/xinit.log +xrdb -query > /tmp/dwm.log while :; do ssh-agent dwm 2>>/tmp/dwm.log || break - echo $$(date "+%Y%m%d-%H%M%S") '=============== restart dwm' >> /tmp/xinit.log done -echo $$(date "+%Y%m%d-%H%M%S") '=============== exit xinit' >> /tmp/xinit.log EOT cat <<'EOT' > ~/.profile @@ -85,6 +86,7 @@ cat <<'EOT' > ~/.profile export PATH=$HOME/dotfiles/bin:$HOME/.local/bin:$PATH export VIM_MODE=enhanced +export DMENU_DEFAULT_OPTS='-i -c -fn monospace:13 -nb #222222 -nf #bbbbbb -sb #5b97f7 -sf #eeeeee -l 20' # auto startx [ -z "$DISPLAY" ] && [ -n "$XDG_VTNR" ] && [ "$XDG_VTNR" -eq "1" ] \ @@ -97,5 +99,4 @@ EOT [ -L "$XDG_CONFIG_HOME/dwm/autostart" ] && rm "$XDG_CONFIG_HOME/dwm/autostart" mkdir -p "$XDG_CONFIG_HOME/dwm" cp "$DIR/config/dwm/autostart" "$XDG_CONFIG_HOME/dwm/autostart" -lnsf "$DIR/config/dwm/statusbar" "$XDG_CONFIG_HOME/dwm/statusbar" lnsf "$DIR/config/autorandr/postswitch" "$XDG_CONFIG_HOME/autorandr/postswitch" diff --git a/thunar/install.sh b/thunar/install.sh old mode 100755 new mode 100644 index 132bed7..5b5cda2 --- a/thunar/install.sh +++ b/thunar/install.sh @@ -1,6 +1,6 @@ #!/bin/sh -DIR=$(readlink -f "$(dirname "$0")") +DIR=$(dirname "$(readlink -f "$0")") . "$DIR/../env.sh" # install ranger diff --git a/tmux/install.sh b/tmux/install.sh old mode 100755 new mode 100644 index c44b9f8..3a866e0 --- a/tmux/install.sh +++ b/tmux/install.sh @@ -1,7 +1,7 @@ #!/bin/sh set -e -DIR=$(readlink -f "$(dirname "$0")") +DIR=$(dirname "$(readlink -f "$0")") . "$DIR/../env.sh" TMUX_VER=3.1b diff --git a/win/wsl.sh b/win/wsl.sh old mode 100755 new mode 100644