use a systemd timer for pending update
This commit is contained in:
parent
bc2dd1220e
commit
dda6743a58
5 changed files with 21 additions and 30 deletions
|
@ -1,29 +0,0 @@
|
||||||
#!/bin/sh
|
|
||||||
|
|
||||||
/usr/local/bin/i3status | while :
|
|
||||||
do
|
|
||||||
read line
|
|
||||||
if echo "${line}" | grep -Pq '^\{"version":\d\}$' ; then
|
|
||||||
echo $line
|
|
||||||
elif echo "${line}" | grep -Pq '^\[$' ; then
|
|
||||||
echo $line
|
|
||||||
else
|
|
||||||
echo -n "["
|
|
||||||
line=`echo "${line}" | sed 's/^,\{0,1\}\[//' | sed 's/\]$//'`
|
|
||||||
NB_UPDATES=`/sbin/checkupdates | /sbin/wc -l`
|
|
||||||
NB_UPDATES_COLOR="#40AA40"
|
|
||||||
if [ $NB_UPDATES -ge 25 ] ; then
|
|
||||||
NB_UPDATES_COLOR="#FF0000"
|
|
||||||
elif [ $NB_UPDATES -ge 10 ] ; then
|
|
||||||
NB_UPDATES_COLOR="#FF8C00"
|
|
||||||
fi
|
|
||||||
echo -n "{"
|
|
||||||
echo -n "\"name\":\"updates\","
|
|
||||||
echo -n "\"full_text\":\"pending updates: ${NB_UPDATES} \","
|
|
||||||
echo -n "\"color\":\"${NB_UPDATES_COLOR}\","
|
|
||||||
echo -n "\"markup\":\"pango\""
|
|
||||||
echo -n "},"
|
|
||||||
echo "$line]" || exit 1
|
|
||||||
echo -n ","
|
|
||||||
fi
|
|
||||||
done
|
|
|
@ -203,7 +203,7 @@ bindsym $mod+r mode "resize"
|
||||||
# finds out, if available)
|
# finds out, if available)
|
||||||
bar {
|
bar {
|
||||||
tray_output primary
|
tray_output primary
|
||||||
status_command "sh ~/.config/i3/bar.sh"
|
status_command "/usr/local/bin/i3status"
|
||||||
position top
|
position top
|
||||||
separator_symbol " | "
|
separator_symbol " | "
|
||||||
colors {
|
colors {
|
||||||
|
|
|
@ -14,6 +14,7 @@ general {
|
||||||
markup = "pango"
|
markup = "pango"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
order += "read_file PENDING_UPDATE"
|
||||||
order += "ipv6"
|
order += "ipv6"
|
||||||
order += "wireless _first_"
|
order += "wireless _first_"
|
||||||
order += "ethernet _first_"
|
order += "ethernet _first_"
|
||||||
|
@ -73,3 +74,8 @@ cpu_usage {
|
||||||
degraded_threshold = 50
|
degraded_threshold = 50
|
||||||
format_above_degraded_threshold = "CPU > %usage"
|
format_above_degraded_threshold = "CPU > %usage"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
read_file PENDING_UPDATE {
|
||||||
|
format = "pending updates: %content"
|
||||||
|
path = "/run/user/1000/pending-updates"
|
||||||
|
}
|
||||||
|
|
5
.config/systemd/user/pending-update.service
Normal file
5
.config/systemd/user/pending-update.service
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
[Unit]
|
||||||
|
Description=Write the number of pending updates in /run/user/%U/pending-updates
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
ExecStart=/bin/sh -c 'checkupdates | wc -l > /run/user/%U/pending-updates'
|
9
.config/systemd/user/pending-update.timer
Normal file
9
.config/systemd/user/pending-update.timer
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
[Unit]
|
||||||
|
Description=Write the number of pending updates in /run/user/%U/pending-updates every 10min
|
||||||
|
|
||||||
|
[Timer]
|
||||||
|
OnBootSec=1s
|
||||||
|
OnUnitActiveSec=10min
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=default.target
|
Loading…
Reference in a new issue