dotfiles

Dash Eclipse's dotfiles
git clone git://ezup.dev/dotfiles.git
Log | Files | Refs | README | LICENSE

status-click-notify.sh (881B)


      1#!/bin/bash
      2
      3get_rtc() {
      4	rtc_path="/sys/class/rtc/rtc0"
      5	printf "$(<${rtc_path}/date) $(<${rtc_path}/time)"
      6}
      7
      8get_uptime() {
      9	proc_uptime=$(</proc/uptime)
     10	local T=${proc_uptime%%.*}
     11        local D=$((T/60/60/24))
     12        local H=$((T/60/60%24))
     13        local M=$((T/60%60))
     14        local S=$((T%60))
     15        [[ $D > 0 ]] && printf '%d days ' $D
     16        [[ $H > 0 ]] && printf '%02d:' $H
     17        [[ $M > 0 ]] && printf '%02d:' $M
     18        printf '%02d\n' $S
     19}
     20
     21echo '{"version": 1, "click_events": true}'
     22echo '['
     23echo '[{"name": "date", "full_text": "date", "separator": false, "color": "#FFA726"}, {"name": "uptime", "full_text": "uptime", "separator": false, "color": "#43A047"}]'
     24
     25while read line; do
     26	if [[ $line == *"name"*"uptime"* ]]; then
     27		notify-send.sh "uptime" "$(get_uptime)"
     28	elif [[ $line == *"name"*"date"* ]]; then
     29		notify-send.sh "date" "$(get_rtc)"
     30	fi
     31done