You are Here:
Linux Lite 6.6 FINAL Released - Support for 22 Languages Added - See Release Announcement Section



A small reminder / notifier script for LL

Author (Read 6976 times)

0 Members and 1 Guest are viewing this topic.

A small reminder / notifier script for LL
« Reply #1 on: August 02, 2018, 03:04:31 PM »
 

kpanic

  • PayPal Supporter
  • Forum Regular
  • *****
  • 162
    Posts
  • Reputation: 67
  • Linux Lite Member
    • View Profile

  • CPU: Core i5 M450

  • MEMORY: 8Gb

  • VIDEO CARD: Nvidia GT216
Hi folks,

I was searching for a lightweight package to give me desktop notifications but
then I noticed that all the necessary things are already in the LL installation,
I just needed a small wrapper script to make things easier.

The script is general purpose - it may be launched from basically any application
and I use it to send messages to the desktop in case the processor, graphics card
or hard-drives are close to their acceptable temperature maximum. Also, I use it
in similar kinds of error-related situations and even send me a "time to go to bed"
message, since I often forget it :)

I don't know if you find this script useful, but here it is if you want to try it.
The installation is as simple as copying the script to some directory and that's
it basically - here are the detailed instructions for testing:

1. Copy the script to the clipboard, open an empty text file and paste it there.
    Save the file into your home directory and give it some name, for example "lite-remind"

2. Make the script executable:
Code: [Select]
chmod 755 ~/lite-remind
3. Create a a small text file, which has 3 short lines in it. The first line will be "Subject" of the
    message and the following two lines will be the message body - keep it short and simple.
    Save it as "msg.txt" into your home directory.

4. Try the script: Open the command line and command:
Code: [Select]
~/lite-remind information ~/msg.txt5. You should see the desktop message appear to the screen for a couple of seconds.
6. Try again, but replace the word 'information' with the word 'warning' or 'error'

And here is the script: ( The ionice / nice parts from LL update notify script, thanks to @Jerry and the LL Team! )

Code: [Select]
#!/bin/bash
# lite-remind v0.1
# A notification script for Linux Lite by kpanic, 2018
# Thanks to Linux Lite Team!
# Reads a message file and shows it on the desktop for
# a couple of seconds using notify-send(1).
#
# Call with two arguments:
# @param1: 'information', 'warning' or 'error'
# @param2: The location of the message file.
#
# Example: lite-remind warning /home/kpanic/message.txt
#
# The first line of the message file will be shown as
# the subject of the message. The lines 2 and 3 will
# be shown as the body of the message. The lines should
# not exceed 28 characters. Keep it short! :)
#
# The first parameter (information, warning or error)
# is the "type" of the message. This affects to which
# icon will be shown with the message. It also affects
# to the scheduling urgency.
#
#
PID=$$
# Scheduling class (3 = Idle)
SCLASS=3
NICE=/usr/bin/nice
NICEVAL=19
REMIND=/usr/bin/notify-send
ARGS="dialog-"
# Verify, that the DISPLAY is set
if [ -z "$DISPLAY" ]; then
    DISPLAY=:0
    export DISPLAY
fi
# exit quietly if not enough arguments,
# since this script may be launched by cron.
if [ "$#" -ne 2 ]; then
    exit 0
fi
if [ ! -r "$2" ]; then
    HEADER="Missing file"
    MSG="Can not read the message file!"
else
    HEADER=$(head -n1 "$2"|cut -c -28)
    MSG=$(head -n3 "$2"|tail -2|cut -c -28)
fi
case "$1" in

       information)
       ;;
       warning)
     
    SCLASS=2
    PRIO="-n 7"
    NICEVAL=8
        ;;
        error)
    SCLASS=2
    PRIO="-n 4"
    NICEVAL=0
        ;;
            *)
        exit 0
        ;;
esac
ionice -c $SCLASS $PRIO -p $PID
$NICE  -n $NICEVAL \
       $REMIND -u normal -c im "$HEADER" "$MSG" -i $ARGS$1
exit 0
 

 

-->
X Close Ad

Linux Lite 6.6 FINAL Released - Support for 22 Languages Added - See Release Announcement Section