about summary refs log tree commit diff
diff options
context:
space:
mode:
authorAzat Bahawi <azahi@teknik.io>2019-12-02 18:03:13 +0300
committerAzat Bahawi <azahi@teknik.io>2019-12-02 18:03:13 +0300
commit29a3bfae91ff4843a9ea2cab5b8cd18393fbdbf4 (patch)
treecc977d45768cd4403b89182bbe26303037a55d41
parentfix build script error and update stack (diff)
Refactor scripts
-rwxr-xr-xbuild31
-rwxr-xr-xbuild-scripts/build-cabal18
-rwxr-xr-xbuild-scripts/build-cabal-sandbox22
-rwxr-xr-xbuild-scripts/build-stack15
-rwxr-xr-xscripts/nsp-console.sh2
-rwxr-xr-xscripts/screenlock.sh7
-rwxr-xr-xscripts/toggle-compton.sh4
-rwxr-xr-xscripts/toggle-redshift.sh2
-rwxr-xr-xscripts/toggle-touchpad.sh2
-rwxr-xr-xscripts/toggle-trackpoint.sh2
-rwxr-xr-xscripts/xmobar/fcitx.sh2
-rwxr-xr-xscripts/xshot-select-upload.sh6
-rwxr-xr-xscripts/xshot-select.sh4
-rwxr-xr-xscripts/xshot-upload.sh6
-rwxr-xr-xscripts/xshot.sh4
15 files changed, 42 insertions, 85 deletions
diff --git a/build b/build
index aa11764..be60f9c 100755
--- a/build
+++ b/build
@@ -8,11 +8,30 @@ shift
 
 cd "$SRC_DIR" || exit 1
 
-cabal new-configure \
-	--enable-optimization \
-	--enable-executable-stripping
+if command -v cabal >/dev/null 2>&1
+then
+    #echo ">>> cabal sandbox init <<<"
+    #cabal sandbox --verbose init || exit 1
 
-cabal new-build
+    echo ">>> cabal new-configure <<<"
+    cabal new-configure \
+        --verbose \
+	    --enable-optimization \
+        --enable-executable-stripping || exit 1
 
-find "$SRC_DIR"/dist-newstyle -type f -executable -name "$EXE_NAME" \
-    -exec mv -u '{}' "$OUT" ';'
+    #echo ">>> cabal install <<<"
+    #cabal install --verbose --only-dependencies || exit 1
+
+    echo ">>> cabal new-build <<<"
+    cabal new-build --verbose || exit 1
+
+    find "$SRC_DIR"/dist-newstyle -type f -executable -name "$EXE_NAME" \
+        -exec mv -u '{}' "$OUT" ';' || exit 1
+else
+    unset STACK_YAML
+
+    echo ">>> stack build <<<"
+    stack build --verbose || exit 1
+
+    ln -f -T "$(stack exec -- which $EXE_NAME)" "$1" || exit 1
+fi
diff --git a/build-scripts/build-cabal b/build-scripts/build-cabal
deleted file mode 100755
index aa11764..0000000
--- a/build-scripts/build-cabal
+++ /dev/null
@@ -1,18 +0,0 @@
-#!/bin/sh -eu
-
-SRC_DIR="$HOME/.xmonad"
-EXE_NAME="xmonad-ng"
-OUT="$1"
-
-shift
-
-cd "$SRC_DIR" || exit 1
-
-cabal new-configure \
-	--enable-optimization \
-	--enable-executable-stripping
-
-cabal new-build
-
-find "$SRC_DIR"/dist-newstyle -type f -executable -name "$EXE_NAME" \
-    -exec mv -u '{}' "$OUT" ';'
diff --git a/build-scripts/build-cabal-sandbox b/build-scripts/build-cabal-sandbox
deleted file mode 100755
index 435fa43..0000000
--- a/build-scripts/build-cabal-sandbox
+++ /dev/null
@@ -1,22 +0,0 @@
-#!/bin/sh -eu
-
-SRC_DIR="$HOME/.xmonad"
-EXE_NAME="xmonad-ng"
-OUT="$1"
-
-shift
-
-cd "$SRC_DIR" || exit 1
-
-cabal sandbox init
-
-cabal configure \
-	--enable-optimization \
-	--enable-executable-stripping
-
-cabal install --only-dependencies
-
-cabal build
-
-find "$SRC_DIR"/dist -type f -executable -name "$EXE_NAME" \
-    -exec mv -u '{}' "$OUT" ';'
diff --git a/build-scripts/build-stack b/build-scripts/build-stack
deleted file mode 100755
index 235b826..0000000
--- a/build-scripts/build-stack
+++ /dev/null
@@ -1,15 +0,0 @@
-#!/bin/sh -eu
-
-SRC_DIR="$HOME/.xmonad"
-EXE_NAME="xmonad-ng"
-OUT="$1"
-
-shift
-
-unset STACK_YAML
-
-cd "$SRC_DIR" || exit 1
-
-stack build
-
-ln -f -T "$(stack exec -- which $EXE_NAME)" "$1"
diff --git a/scripts/nsp-console.sh b/scripts/nsp-console.sh
index 8923ea2..b83d526 100755
--- a/scripts/nsp-console.sh
+++ b/scripts/nsp-console.sh
@@ -4,5 +4,5 @@ if tmux list-sessions | grep -q "scratchpad"
 then
     tmux attach-session -t "scratchpad"
 else
-    tmux new-session -s "scratchpad" -n "scratchpad" -c "${HOME}"
+    tmux new-session -s "scratchpad" -n "scratchpad" -c "$HOME"
 fi
diff --git a/scripts/screenlock.sh b/scripts/screenlock.sh
deleted file mode 100755
index fda4556..0000000
--- a/scripts/screenlock.sh
+++ /dev/null
@@ -1,7 +0,0 @@
-#!/bin/sh
-
-i3lock \
-    --no-unlock-indicator \
-    --image "${HOME}/pictures/wallpapers/mill-lock.png" \
-    --pointer default \
-    --ignore-empty-password
diff --git a/scripts/toggle-compton.sh b/scripts/toggle-compton.sh
index ee3c880..7c36b2f 100755
--- a/scripts/toggle-compton.sh
+++ b/scripts/toggle-compton.sh
@@ -1,8 +1,8 @@
-#!/usr/bin/env bash
+#!/bin/sh
 
 if ! pgrep compton
 then
-    compton -b --config "${XDG_CONFIG_HOME}/compton.conf"
+    compton -b --config "$XDG_CONFIG_HOME/compton.conf"
 else
     pkill compton
 fi
diff --git a/scripts/toggle-redshift.sh b/scripts/toggle-redshift.sh
index 4dbcc38..bd70f60 100755
--- a/scripts/toggle-redshift.sh
+++ b/scripts/toggle-redshift.sh
@@ -2,7 +2,7 @@
 
 if ! pgrep redshift
 then
-    redshift -c "${XDG_CONFIG_HOME}/redshift.conf" &
+    redshift -c "$XDG_CONFIG_HOME/redshift.conf" &
     disown redshift
 else
     pkill redshift
diff --git a/scripts/toggle-touchpad.sh b/scripts/toggle-touchpad.sh
index 7a82391..449bd5b 100755
--- a/scripts/toggle-touchpad.sh
+++ b/scripts/toggle-touchpad.sh
@@ -3,7 +3,7 @@
 ID=$(xinput list | grep -Eo 'TouchPad\s*id\=[0-9]{1,2}' | grep -Eo '[0-9]{1,2}')
 STATE=$(xinput list-props "$ID" | awk '/Device Enabled/ {print $4}')
 
-if [ "$STATE" -eq 1 ]
+if [ "$STATE" = 1 ]
 then
     xinput disable "$ID"
 else
diff --git a/scripts/toggle-trackpoint.sh b/scripts/toggle-trackpoint.sh
index 2d54670..1429dcf 100755
--- a/scripts/toggle-trackpoint.sh
+++ b/scripts/toggle-trackpoint.sh
@@ -3,7 +3,7 @@
 ID=$(xinput list | grep -Eo 'TrackPoint\s*id\=[0-9]{1,2}' | grep -Eo '[0-9]{1,2}')
 STATE=$(xinput list-props "$ID" | awk '/Device Enabled/ {print $4}')
 
-if [ "$STATE" -eq 1 ]
+if [ "$STATE" = 1 ]
 then
     xinput disable "$ID"
 else
diff --git a/scripts/xmobar/fcitx.sh b/scripts/xmobar/fcitx.sh
index 5538f50..48eefa0 100755
--- a/scripts/xmobar/fcitx.sh
+++ b/scripts/xmobar/fcitx.sh
@@ -2,7 +2,7 @@
 
 STATUS="$(fcitx-remote)"
 
-if   [ "$STATUS" = 0 ]
+if [ "$STATUS" = 0 ]
 then
     OUT="Off"
 elif [ "$STATUS" = 1 ]
diff --git a/scripts/xshot-select-upload.sh b/scripts/xshot-select-upload.sh
index 777eb87..040251e 100755
--- a/scripts/xshot-select-upload.sh
+++ b/scripts/xshot-select-upload.sh
@@ -1,7 +1,7 @@
 #!/bin/sh
 
-PIC="${HOME}/pictures/screenshots/$(date +%Y-%m-%d_%H-%M-%S).png"
+PIC="$HOME/pictures/screenshots/$(date +%Y-%m-%d_%H-%M-%S).png"
 
-maim --format=png --hidecursor --quality 8 --select "${PIC}" && \
-    curl --form "file=@${PIC}" "https://0x0.st" | \
+maim --format=png --hidecursor --quality 8 --select "$PIC" && \
+    curl --form "file=@$PIC" "https://0x0.st" | \
     xclip -quiet
diff --git a/scripts/xshot-select.sh b/scripts/xshot-select.sh
index fc714c8..a0913a5 100755
--- a/scripts/xshot-select.sh
+++ b/scripts/xshot-select.sh
@@ -1,5 +1,5 @@
 #!/bin/sh
 
-PIC="${HOME}/pictures/screenshots/$(date +%Y-%m-%d_%H-%M-%S).png"
+PIC="$HOME/pictures/screenshots/$(date +%Y-%m-%d_%H-%M-%S).png"
 
-maim --format=png --hidecursor --quality 8 --select "${PIC}"
+maim --format=png --hidecursor --quality 8 --select "$PIC"
diff --git a/scripts/xshot-upload.sh b/scripts/xshot-upload.sh
index 0dcd1ec..ed037de 100755
--- a/scripts/xshot-upload.sh
+++ b/scripts/xshot-upload.sh
@@ -1,7 +1,7 @@
 #!/bin/sh
 
-PIC="${HOME}/pictures/screenshots/$(date +%Y-%m-%d_%H-%M-%S).png"
+PIC="$HOME/pictures/screenshots/$(date +%Y-%m-%d_%H-%M-%S).png"
 
-maim --format=png --hidecursor --quality 8 "${PIC}" && \
-    curl --form "file=@${PIC}" "https://0x0.st" | \
+maim --format=png --hidecursor --quality 8 "$PIC" && \
+    curl --form "file=@$PIC" "https://0x0.st" | \
     xclip -quiet
diff --git a/scripts/xshot.sh b/scripts/xshot.sh
index 0fbe40e..046315d 100755
--- a/scripts/xshot.sh
+++ b/scripts/xshot.sh
@@ -1,5 +1,5 @@
 #!/bin/sh
 
-PIC="${HOME}/pictures/screenshots/$(date +%Y-%m-%d_%H-%M-%S).png"
+PIC="$HOME/pictures/screenshots/$(date +%Y-%m-%d_%H-%M-%S).png"
 
-maim --format=png --hidecursor --quality 8 "${PIC}"
+maim --format=png --hidecursor --quality 8 "$PIC"

Consider giving Nix/NixOS a try! <3