Score:0

How to add device plug in sound in ubuntu 20.04?

dz flag

as you know in windows when we plug something theres a tune that plays how can i add one in my ubuntu machine? v20.04 thank you

Score:0
cn flag

I already have this bash script in my Ubuntu 18.04, not very cleaner but it works properly.

#!/bin/bash
inotifywait -rm /dev/disk/by-label/ -e CREATE -e DELETE | while read path action file; do
if [ $action = CREATE ]; then
   dev=$(ls -lt1 /dev/disk/by-label/ | grep -o "sd[b-z][0-9]" | head -n1)
   size=$(lsblk | grep $dev | awk '{print $4}')

   aplay path/to/the/file1.wav &
   notify-send "$file"  "Device $size pluggued"
else
   aplay path/to/the/file2.wav &
   notify-send "$file"  "Device unpluggued"
fi
done &
exit

Add it to the startup applications and you'll have a sound and notification alert on every device plug. Hope this help you.

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.