summaryrefslogtreecommitdiff
path: root/i3/.config/i3blocks/bin/repos
diff options
context:
space:
mode:
authorUrbain Vaes <urbain@vaes.uk>2018-02-21 12:18:32 +0000
committerUrbain Vaes <urbain@vaes.uk>2018-02-21 16:46:29 +0000
commitb9ea238dd7e8a56b1d171cdc76e405bb2a8584dd (patch)
treed693deb61965b724cd8630e0a061e5e762341c9c /i3/.config/i3blocks/bin/repos
parent68d822599f074c24505eea2329bfc80e2745feab (diff)
Improve i3 status
Diffstat (limited to 'i3/.config/i3blocks/bin/repos')
-rwxr-xr-xi3/.config/i3blocks/bin/repos28
1 files changed, 28 insertions, 0 deletions
diff --git a/i3/.config/i3blocks/bin/repos b/i3/.config/i3blocks/bin/repos
new file mode 100755
index 0000000..48b8b27
--- /dev/null
+++ b/i3/.config/i3blocks/bin/repos
@@ -0,0 +1,28 @@
+#!/usr/bin/env bash
+
+color_changes() {
+ if [[ $1 -gt 100 ]]; then
+ echo 'red'
+ elif [[ $1 -gt 10 ]]; then
+ echo 'yellow'
+ elif [[ $1 -gt 0 ]]; then
+ echo 'lightgreen'
+ else
+ echo 'gray'
+ fi
+}
+
+if command -v mr > /dev/null; then
+ total_changes=0
+ for title_dir in $BLOCK_INSTANCE; do
+ title="${title_dir%:*}"
+ cd "${title_dir##*:}" || exit
+ n_changes=$(mr status | grep -vc "^$\\|^mr")
+ [[ n_changes -gt total_changes ]] && total_changes=n_changes
+ color=$(color_changes "$n_changes")
+ output+="$sep$title:<span color='$color'>$n_changes</span>"
+ sep=" - "
+ done
+ color_label=$(color_changes $total_changes)
+ echo "<span color='$color_label'> </span> $output"
+fi