LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 03-27-2017, 10:46 AM   #1
d_K
Member
 
Registered: Aug 2016
Posts: 32

Rep: Reputation: Disabled
Smile This should be a really easy task.


On xfce, I'm looking to play a custom sound whenever a notification pops up. Here's the pseudocode:

Code:
while (true){
if [notify-send]
   /usr/bin/play -q ~/sounds/notification.wav
}
(sox is required for the command "play".)
 
Old 03-27-2017, 10:58 AM   #2
Ru1138
LQ Newbie
 
Registered: Aug 2014
Distribution: Antergos
Posts: 29

Rep: Reputation: Disabled
Quote:
Originally Posted by d_K View Post
On xfce, I'm looking to play a custom sound whenever a notification pops up. Here's the pseudocode:

Code:
while (true){
if [notify-send]
   /usr/bin/play -q ~/sounds/notification.wav
}
(sox is required for the command "play".)
I found this via Google: https://forum.xfce.org/viewtopic.php?id=8618

It doesn't directly apply to your issue (or does it?), but it may give you a few things to check.
 
Old 03-27-2017, 11:03 AM   #3
d_K
Member
 
Registered: Aug 2016
Posts: 32

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by Ru1138 View Post
I found this via Google: https://forum.xfce.org/viewtopic.php?id=8618

It doesn't directly apply to your issue (or does it?), but it may give you a few things to check.
notifyd doesn't support system sounds. There's requests for it, but the devs haven't gotten to them yet apparently. For now I'm looking for a theoretically easy workaround.
 
Old 03-27-2017, 11:08 AM   #4
Ru1138
LQ Newbie
 
Registered: Aug 2014
Distribution: Antergos
Posts: 29

Rep: Reputation: Disabled
Quote:
Originally Posted by d_K View Post
notifyd doesn't support system sounds. There's requests for it, but the devs haven't gotten to them yet apparently. For now I'm looking for a theoretically easy workaround.
Okay. I don't really know what else to do. Best of luck on finding solutions though!
 
Old 03-27-2017, 11:31 AM   #5
schneidz
LQ Guru
 
Registered: May 2005
Location: boston, usa
Distribution: fedora-35
Posts: 5,313

Rep: Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918
this seems related
Code:
[schneidz@hyper ~]$ cat ./egg.ksh
#!/bin/bash
# Filename: progbar-timer.sh
# Version: 110212
# Author: robz
# Improved from the "Egg Timer" script, a countdown timer with progress bar.
# This one has an indication of time remaining provided by Zenity's progress
# bar function. As usual you'll need to find a sound and icon for the variables
# below, you might find the icon variable is correct, check the directory.

ICON=/usr/share/app-install/icons/kalarm.png              # Existing icon?
SOUND=/home/schneidz/music/Finding-Forever/01-Intro--Intro--Intro--Intro--Intro--Intro--Intro--Intro--Intro--Intro--Intro--Intro--Intro--Intro--Intro--Intro.mp3                               # Your sound pref.

COUNT=$(zenity --title "Egg Timer" --window-icon $ICON --text "No decimals"\
    --entry-text "eg. 10s or 5m or 2h" --entry)           # Input dialogue.
if [ $? = 1 ]; then exit $?; fi

# Determine number of seconds to count down from depending on input suffix.
case "${COUNT: -1}" in
    "S" | "s" ) COUNT=$(echo $COUNT | sed -s "s/[Ss]//") ;;
    "M" | "m" ) COUNT=$(echo $COUNT | sed -s "s/[Mm]//"); ((COUNT*=60)) ;;
    "H" | "h" ) COUNT=$(echo $COUNT | sed -s "s/[Hh]//"); ((COUNT*=3600)) ;;
    *         ) zenity --error --text "<span color=\"red\"><b>\
    \nUse the form of 10s or 5m or 2h\nNo decimals allowed either.</b></span>"
    sh -c "$0"                                            # On error restart.
    exit ;;
esac

START=$COUNT                                              # Set a start point.

until [ "$COUNT" -eq "0" ]; do                            # Countdown loop.
    ((COUNT-=1))                                          # Decrement seconds.
    PERCENT=$((100-100*COUNT/START))                      # Calc percentage.
    echo "#Time remaining$(echo "obase=60;$COUNT" | bc)"  # Convert to H:M:S.
    echo $PERCENT                                         # Outut for progbar.
    sleep 1
done | zenity --title "Egg Timer" --progress --percentage=0 --text=""\
    --window-icon=$ICON --auto-close                      # Progbar/time left.
if [ $? = 1 ]; then exit $?; fi
notify-send -i $ICON "Egg Timer > ## TIMES UP ##"         # Attention finish!
/usr/bin/canberra-gtk-play --volume 4 -f $SOUND           # Ding-dong finish!
zenity --notification --window-icon="$ICON"\
    --text "Egg Timer > ## TIMES UP ##"                   # Indicate finished!
 
Old 03-27-2017, 11:37 AM   #6
d_K
Member
 
Registered: Aug 2016
Posts: 32

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by schneidz View Post
this seems related
Code:
notify-send -i $ICON "Egg Timer > ## TIMES UP ##"         # Attention finish!
/usr/bin/canberra-gtk-play --volume 4 -f $SOUND           # Ding-dong finish!
Looks to be unrelated, as you can see there the canberra sound just follows another line that just happens to be after notify-send'ing a notification. There's no, if you like, "system event checking" going on.

Last edited by d_K; 03-27-2017 at 11:39 AM.
 
  


Reply

Tags
alerts, notifications, notify, xfce



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Is disabling udev in slackware 14.0 an easy task? stf92 Slackware 38 10-12-2013 01:09 PM
How to kill a task when the task won't die? Ook Slackware 10 03-27-2012 08:13 AM
Python - Problems when trying to run a task at log on task on windows doomloard Programming 2 06-18-2011 04:31 PM
launching a task from cli and "divorcing it from terminal task wufo Linux - General 6 02-11-2011 11:32 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 02:08 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration