commit 0c396c0651e5022ee385fb2bf0e9f685020bf766 parent 2775c7b900c687176399ada194ac01b280c7d6bd Author: Wim Dupont <wim@wimdupont.com> Date: Sun, 5 May 2024 20:38:46 +0200 added sinstaller Diffstat:
M | README.adoc | | | 10 | +++++++++- |
A | bin/sinstaller | | | 134 | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
2 files changed, 143 insertions(+), 1 deletion(-)
diff --git a/README.adoc b/README.adoc @@ -114,7 +114,15 @@ for the same name as the chosen file then pass-otp will be used to copy the OTP * https://git.zx2c4.com/password-store/[pass] * https://git.suckless.org/dmenu/[dmenu] * https://github.com/astrand/xclip[xclip] - + +== link:bin/sinstaller[sinstaller] + +Installation and patching helper for https://git.suckless.org/[suckless] software. Adjust PROGRAMS and PATCHES arrays to your liking before running. + +.Requires: + +* https://gitlab.gnome.org/GNOME/zenity[zenity] + == link:bin/radio[radio] Uses dmenu to browse and play online radio stations saved in a textfile (default in ~/.config/scripts/radiostations). The textfile should consist of a searchname and the URL separated by a semicolon (;) and with a new line for each new station. diff --git a/bin/sinstaller b/bin/sinstaller @@ -0,0 +1,134 @@ +#!/bin/bash + +source ~/.config/scripts/properties + +all=0 +save_diff=0 +while getopts "as" arg; do + case $arg in + a) all=1;; + s) save_diff=1;; + esac +done + +shift $((OPTIND-1)) + +program=$1 + +readonly ROOT_DIR=$HOME/repositories/suckless +readonly GIT_BASE_URL=https://git.suckless.org + +PROGRAMS=( + "dmenu" + "dwm" + "dwmstatus" + "ii" + "libgrapheme" + "lchat" + "sic" + "slock" + "st" +) + +PATCHES=( + "st;https://st.suckless.org/patches/alpha_focus_highlight/st-focus-20230610-68d1ad9.diff" + "st;https://st.suckless.org/patches/scrollback/st-scrollback-0.8.5.diff" + "dwm;https://dwm.suckless.org/patches/statuspadding/dwm-statuspadding-6.3.diff" + "dwm;https://dwm.suckless.org/patches/alpha/dwm-fixborders-6.2.diff" + "slock;https://tools.suckless.org/slock/patches/background-image/slock-background-image-20220318-1c5a538.diff" +) + +download(){ + declare -r PROGRAM=$1 + + mkdir -p "${ROOT_DIR}" + mkdir -p "${ROOT_DIR}/patches/$PROGRAM" + + cd "${ROOT_DIR}" + + git clone "${GIT_BASE_URL}/$PROGRAM" + cd $PROGRAM + git checkout -b patched + + download_patches "$PROGRAM" +} + +download_patches(){ + declare -r PROGRAM=$1 + rm "$ROOT_DIR/patches/$PROGRAM/"* + i=0 + for patch in "${PATCHES[@]}" + do + name=$(echo "$patch" | cut -f1 -d ';') + + if [[ "${name}" == "${PROGRAM}" ]]; then + ((i++)) + patch_url=$(echo "$patch" | cut -f2 -d ';') + curl "$patch_url" > "$ROOT_DIR/patches/$PROGRAM/$i-${patch_url##*/}" + fi + done +} + +cleanup_and_patch(){ + declare -r PROGRAM=$1 + cd "${ROOT_DIR}/$PROGRAM" + + git checkout patched + + git reset --hard HEAD + git clean -xf + + git checkout master + git pull + + git branch -D patched + git checkout -b patched + + for file in "$ROOT_DIR/patches/$PROGRAM/"*; do + test -f $file || continue; + patch -i $file + done + + git add . + git -c commit.gpgsign=false commit -m "patched" +} + +patch_config(){ + declare -r PROGRAM=$1 + cd "${ROOT_DIR}/$PROGRAM" + + git checkout patched + + config_file="$ROOT_DIR/patches-config/$PROGRAM-config.diff" + test -f "$config_file" && patch -i "$config_file" +} + + +save_config(){ + declare -r PROGRAM=$1 + cd "${ROOT_DIR}/$PROGRAM" + git diff > "$ROOT_DIR/patches-config/$PROGRAM-config.diff" +} + +execute_installer(){ + declare -r PROGRAM=$1 + + [[ ! -d "${ROOT_DIR}/$PROGRAM" ]] && download $PROGRAM + test "$save_diff" == 1 && save_config $PROGRAM + cleanup_and_patch $PROGRAM + patch_config $PROGRAM + + cd "${ROOT_DIR}/$PROGRAM" + sudo make clean install +} + +test "$all" == 0 && [ -z $program ] && notify-send "Insufficient parameters" "Either use -a for all or specifify program as arg." && exit 1; + +if [[ "$all" == 1 ]]; then + for i in "${PROGRAMS[@]}" + do + execute_installer $i + done +else + execute_installer $program +fi