dotfiles

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

status-click-notify.sh (936B)


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