summaryrefslogtreecommitdiffstats
path: root/scripts/emerge-current.sh
blob: 53e7a19265cb0d9fe0c3e2f1d7b96e2c2074ce5b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/bin/bash
# emerge-current.sh by Hellf[i]re
#
# This script is designed to read the name of the last package compiled.
#
# As this script does read the entirety of emerge.log, it will be rather
# heavy on the CPU.  It shouldn't be enough to be noticable on newer (2.0Ghz+)
# processors, but it still should not be run more often than every 30 seconds.
#
# Usage:
# .conkyrc:     ${execi [time] /path/to/script/emerge-current.sh}
#
# Usage Example
#               ${execi 30 /home/youruser/scripts/emerge-current.sh}

if [ -n "$1" ]; then
    num=$1
else
    num=1
fi

tac /var/log/emerge.log |\
grep 'Compiling' |\
head -n $num |\
sed -e 's/.*(//' |\
sed -e 's/::.*)//' |\
sed -e '2,$ { s|^[^/]\+/|| }' |\
sed -e '2,$ { s|-[0-9.]\+\(-r[0-9]\+\)\?$|| }' |\
head -n $num | sed -e "2 { s/^/   / }" -e  "2,$ { :a ; N ; s/\n/, /; ta }" |\
cut -d \) -f 1