Add script for time notification

This commit is contained in:
Ngô Ngọc Đức Huy 2021-03-19 23:01:10 +07:00
parent d157d92a7f
commit f1a68680a8
Signed by: huyngo
GPG Key ID: 904AF1C7CDF695C3
2 changed files with 8 additions and 4 deletions

6
battery-notification.sh Normal file → Executable file
View File

@ -3,16 +3,14 @@
# Run this script as a cronjob every 5 minutes or so, to get notifications when
# battery percentage goes below 30% or above 80%.
# Cronjob line example:
# */5 * * * * /bin/bash /path/to/battery_health_notifications.sh
# */5 * * * * /bin/bash /path/to/battery-notification.sh
# This line is to make notify-send always work, also when run in a crontab.
# https://askubuntu.com/questions/298608/notify-send-doesnt-work-from-crontab/346580#346580
#
# Credits to gitaarik: https://gitlab.com/gitaarik/battery-health-notifications/-/blob/master/battery_health_notifications.sh
export $(grep -z DBUS_SESSION_BUS_ADDRESS /proc/$(pgrep -u $LOGNAME gnome-session | head -n 1)/environ | tr '\0' '\n')
wall "It's good"
# export $(grep -z DBUS_SESSION_BUS_ADDRESS /proc/$(pgrep -u $LOGNAME gnome-session | head -n 1)/environ | tr '\0' '\n')
BATTERY_PATH=$(upower -e | grep battery)
LINE_POWER_PATH=$(upower -e | grep line_power)

6
time-notification.sh Executable file
View File

@ -0,0 +1,6 @@
#!/bin/bash
# Run this as a cron job to announce stop time
# 0 22 * * * /bin/bash /path/to/time-notification.sh
mpc stop
xmessage "Please stop working." & mplayer /usr/lib64/libreoffice/share/gallery/sounds/explos.wav