This forum has been archived. All content is frozen. Please use KDE Discuss instead.

Automating knotify4 notifications (stopping popup alerts)

Tags: None
(comma "," separated)
vahid
Registered Member
Posts
32
Karma
0
Ok After some thoughts about whilst watching films doing presentations, KDE has a feature to pop and make and a sound for when notifications occur for any given application.
You can use below script - but you must first visit notifications and disable all the tick boxes for audio and popup for ALL fields in ALL application you wish to control, the script below is generic and moves ALL configs created out of the way and kills knotify which then picks up new config.
It moves out of the way to enable originial config aka notification.sh start
It puts back your config which disables all notifications you disabled aka notification.sh stop


Code: Select all
#!/bin/sh
home=`kde4-config --localprefix|sed -e "s/\.kde\///g"`
config="$home.kde/share/config/"
workdir="$home/scripts/workdir"

if test -e $workdir; then mkdir -p $workdir; fi

currentuser=`whoami`
if [ $currentuser = "root" ]; then echo "error root can not run this, run as normal user"; exit; fi;

case "${1}" in
("start")
 find $config -name *.notifyrc -exec mv {} $workdir/ ;
 kill -9 `pgrep knotify4`
 echo "Ok Notifications for Powerdevil has now been re-enabled "
    ;;
("stop")
 find $workdir -name *.notifyrc -exec mv {} $config/ ;
kill -9 `pgrep knotify4`
echo "Ok Notifications for Powerdevil have now been stopped Danke "
    ;;
(*)
    echo "$0 {start|stop}"
    exit
    ;;
esac




so in the code for watching-film.sh

you can obviously first save this script lets say notify.sh in scripts folder.

then in the bit that it disables screen saver add one line
/home/user/scripts/notify.sh stop

and when screen saver is re-enabled you can do
/home/user/scripts/notify.sh start

I have been testing script and it works I run ./notify.sh stop and then pull out power cable and knotify4 stops alerting the audio and actual pop up message of power cable being pulled out
I then run
./notify.sh and pull out cable again and it pops up and makes noise

Last edited by vahid on Sat Jul 04, 2009 11:46 am, edited 2 times in total.
vahid
Registered Member
Posts
32
Karma
0
View This script for automated powerdevil notification disabler.

The article explains how you can convert any RC file to a one line shell script variable which can then be used on any KDE machine.

The thing with notification is that you first need to edit notification settings from system settings - this then generates the specific RC file with your specific settings which in all cases will be null values for popup and sound in the config.

This means on any new machine you setup you also need to re-tweek the notifications.

Using this script from this post if you first setup one machine exactly as you want it with all notifications disabled then run the script this will generated all the variables for ALL notifications once you have the shell script you can either post the generated notification script to the other post or re-use it yourself on any other KDE desktop.

I hope it makes better sense

Last edited by vahid on Sat Jul 04, 2009 11:40 am, edited 2 times in total.
User avatar
anda_skoa
KDE Developer
Posts
783
Karma
4
OS
Just some ideas for improvements:

- don't assume a certain home directory or only do it if $HOME is not set
- check kde4-config --localprefix and the first directory in kde4-config --path config

Cheers,
_


anda_skoa, proud to be a member of KDE forums since 2008-Oct.
vahid
Registered Member
Posts
32
Karma
0
thanks I have updated the above script it is a lot easier and will work perfectly.


Bookmarks



Who is online

Registered users: bartoloni, Bing [Bot], Google [Bot], Sogou [Bot]