summaryrefslogtreecommitdiff
path: root/i3/.config/i3blocks
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
parent68d822599f074c24505eea2329bfc80e2745feab (diff)
Improve i3 status
Diffstat (limited to 'i3/.config/i3blocks')
-rwxr-xr-xi3/.config/i3blocks/bin/battery51
-rwxr-xr-xi3/.config/i3blocks/bin/email5
-rwxr-xr-xi3/.config/i3blocks/bin/repos28
-rwxr-xr-xi3/.config/i3blocks/bin/updates13
-rwxr-xr-xi3/.config/i3blocks/bin/wifi10
-rw-r--r--i3/.config/i3blocks/config67
6 files changed, 142 insertions, 32 deletions
diff --git a/i3/.config/i3blocks/bin/battery b/i3/.config/i3blocks/bin/battery
new file mode 100755
index 0000000..b345f16
--- /dev/null
+++ b/i3/.config/i3blocks/bin/battery
@@ -0,0 +1,51 @@
+#!/usr/bin/env bash
+
+if [ ! -d /sys/class/power_supply/BAT0 ]; then
+ echo "<span color='gray'></span> No battery"
+ exit
+fi
+
+output="$(acpi -b)"
+remaining_time=$(echo "$output" | grep -o "[0-9][0-9]:[0-9][0-9]")
+<<<<<<< HEAD
+
+if [ -d /sys/class/power_supply/BAT0 ]; then
+ now_charge=$(cat /sys/class/power_supply/BAT0/now_charge)
+ full_charge=$(cat /sys/class/power_supply/BAT0/full_charge)
+ charge=$(( (100*now_charge) / full_charge ))
+else
+ echo ""
+ exit
+fi
+=======
+now_charge=$(cat /sys/class/power_supply/BAT0/now_charge)
+full_charge=$(cat /sys/class/power_supply/BAT0/full_charge)
+charge=$(( (100*now_charge) / full_charge ))
+# charge=$(echo "$output" | grep -oP "..(?=%)")
+>>>>>>> de29d3a... Add minor updates
+
+if grep -q "Discharging" <(echo "$output"); then
+ remaining_time=$(echo "$output" | grep -oP "..:..(?=:.. remaining)")
+ if [[ $charge -lt 20 ]]; then
+ icon=""
+ color="#FF0000"
+ elif [[ $charge -lt 40 ]]; then
+ icon=""
+ color="#FFAE00"
+ elif [[ $charge -lt 60 ]]; then
+ icon=""
+ color="#FFF600"
+ elif [[ $charge -lt 80 ]]; then
+ icon=""
+ color="#A8FF00"
+ else
+ icon=""
+ color="#00FF00"
+ fi
+else
+ icon=
+ color="lightblue"
+fi
+
+echo "<span color='$color'>$icon</span> $charge% ($remaining_time)"
+echo "$icon $charge% ($remaining_time)"
diff --git a/i3/.config/i3blocks/bin/email b/i3/.config/i3blocks/bin/email
index ab875e0..f83f4b0 100755
--- a/i3/.config/i3blocks/bin/email
+++ b/i3/.config/i3blocks/bin/email
@@ -1,10 +1,9 @@
#!/usr/bin/env bash
nMails=$(find $HOME/.mail -path '*/new/*' -type f -not -path '*/rss/*' -not -path '*/lists/*' | wc -l)
-echo -e "${nMails}\n${nMails}"
if [[ ${nMails} -eq 0 ]]; then
- echo \#FFFFFF
+ echo -e "<span color='gray'></span> ${nMails}"
else
- echo \#00FF00
+ echo -e "<span color='#00FF00'> ${nMails}</span>"
fi
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
diff --git a/i3/.config/i3blocks/bin/updates b/i3/.config/i3blocks/bin/updates
new file mode 100755
index 0000000..325b485
--- /dev/null
+++ b/i3/.config/i3blocks/bin/updates
@@ -0,0 +1,13 @@
+#!/usr/bin/env bash
+
+if command -v checkupdates > /dev/null; then
+ n_updates=$(checkupdates | wc -l)
+ if [[ n_updates -gt 50 ]]; then
+ color='red'
+ elif [[ n_updates -gt 10 ]]; then
+ color='yellow'
+ else
+ color='gray'
+ fi
+ echo "<span color='$color'></span> $n_updates"
+fi
diff --git a/i3/.config/i3blocks/bin/wifi b/i3/.config/i3blocks/bin/wifi
index 434c508..bc24672 100755
--- a/i3/.config/i3blocks/bin/wifi
+++ b/i3/.config/i3blocks/bin/wifi
@@ -6,10 +6,16 @@ wifi_address=$(ip addr show wlp2s0 2>/dev/null | grep -oP -m1 "(?<=inet ).*(?=/)
eth_address=$(ip addr show eno1 2>/dev/null | grep -oP -m1 "(?<=inet ).*(?=/)")
if [[ -n $eth_address ]]; then
- echo "eno1: $eth_address"
+ full_text="eno1: $eth_address"
+ ip_addr="$eth_address"
elif [[ -n $wifi_address ]]; then
- echo "wlp2s0: (${quality}% at ${ssid}) ${wifi_address}"
+ full_text="wlp2s0: (${quality}% at ${ssid}) ${wifi_address}"
+ ip_addr="$wifi_address"
else
echo "No connection"
fi
+case $BLOCK_BUTTON in
+ 1) echo "$full_text" ;;
+ *) echo -e "$ip_addr" ;;
+esac
diff --git a/i3/.config/i3blocks/config b/i3/.config/i3blocks/config
index 2e149bf..48faf62 100644
--- a/i3/.config/i3blocks/config
+++ b/i3/.config/i3blocks/config
@@ -26,49 +26,62 @@
# Each block command defaults to the script name to avoid boilerplate.
command=/usr/lib/i3blocks/$BLOCK_NAME
separator_block_width=15
-markup=none
+markup=pango
+[primary]
+label=<span color='gray'></span>
+command=echo "$(xclip -o | cut -c1-9)"
+min_width=15
+interval=5
-# Volume indicator
-#
-# The first parameter sets the step (and units to display)
-# The second parameter overrides the mixer selection
-# See the script for details.
-[volume]
-label=♪
+[clipboard]
+label=<span color='gray'></span>
+command=echo "$(xclip -o -selection "clipboard" | cut -c1-9)"
instance=Master
interval=5
-[wifi]
-label=W:
-command=~/dotfiles/i3/.config/i3blocks/bin/wifi
-separator=true
+[volume]
+label=<span color='gray'></span>
+instance=Master
interval=5
+[repos]
+command=~/dotfiles/i3/.config/i3blocks/bin/repos
+instance=Phd:/home/urbain/phd Home:/home/urbain
+interval=1000
+
+[updates-arch]
+command=~/dotfiles/i3/.config/i3blocks/bin/updates
+interval=1000
+
[email]
-label=Mail:
command=~/dotfiles/i3/.config/i3blocks/bin/email
separator=true
interval=5
-[disk]
-label=HOME
-interval=30
-
-[cpu_usage]
-label=CPU
-interval=10
-min_width=CPU: 100.00%
+[wifi]
+label=<span color='gray'></span>
+command=~/dotfiles/i3/.config/i3blocks/bin/wifi
+separator=true
+interval=5
[battery]
-label=BAT
+command=~/dotfiles/i3/.config/i3blocks/bin/battery
interval=30
+[diskhome]
+label=<span color='gray'></span>
+command=/usr/lib/i3blocks/disk
+instance=/home/urbain
+interval=60
+
+[diskroot]
+label=<span color='gray'></span>
+command=/usr/lib/i3blocks/disk
+instance=/
+interval=60
+
[time]
+label=<span color='gray'></span>
command=date '+%Y-%m-%d %H:%M'
interval=5
-
-[mediaplayer]
-instance=spotify
-interval=5
-signal=10