We have moved to a new Sailfish OS Forum. Please start new discussions there.
1

Running shell script from *.desktop file

asked 2020-04-09 18:41:21 +0200

mortenbo gravatar image

updated 2020-04-09 18:48:23 +0200

Hi

I have an odd problem. I have the made this little script to record sound:

------ record.sh begin ------

   #!/bin/sh

   if [ -n "$(ps -e | grep parec)" ]; then
     killall parec;
     pacmd set-source-volume source.droid 65536;
     exit 0;
   fi

   pacmd set-source-volume source.droid 229376
   parec s.mp3

-------- record.sh end --------

When run the first time it sets the recording volume to 350% and records sound to "s.mp3". When run again it stops recording and resets the recording volume to 100%. I have made a *.desktop file and placed it in /usr/share/applications:

   [Desktop Entry]
   Name=Recorder
   Exec=/home/nemo/bin/record.sh
   Icon=/home/nemo/icons/recorder.jpeg
   Type=Application
   Terminal=false

When I execute the script from a terminal it works as intended. When I execute the script from a *.desktop file on my workstation it works as intended.

But when I execute it from the *.desktop file om my phone it starts the recording but when I click on the icon the second time it doesn't stop recording and there is also an annoying startup icon with a rotating circle popping up for about 10 seconds.

I wonder why it does not work on my phone?

edit retag flag offensive close delete

Comments

Sailfish launcher .desktop files are not designed for this :( It forces single-instance way of executing appliactions

coderus ( 2020-04-09 18:58:33 +0200 )edit

All right, thanks. What are my options, then?

mortenbo ( 2020-04-09 19:00:55 +0200 )edit

write application :)

coderus ( 2020-04-09 19:47:10 +0200 )edit

Just a guess.
Maybe it will work with last line changed to:

parec s.mp3 &
peterleinchen ( 2020-04-10 00:50:11 +0200 )edit

@peterleinchen, alas it makes no difference.

mortenbo ( 2020-04-10 09:57:38 +0200 )edit

1 Answer

Sort by » oldest newest most voted
0

answered 2020-04-23 11:26:37 +0200

nas gravatar image

updated 2020-04-23 11:28:35 +0200

@mortenbo ok, I think I made it to work! Add in a new line in your .desktop:

X-Nemo-Single-Instance=no

and that's it !

Also, if you want timestamp in the filename try:

parec $(date +"%Y%m%d-%H%M%S")_s.mp3
edit flag offensive delete publish link more

Comments

Thanks @nas!

However, I still have the annoying startup icon hovering for about 10 seconds whenever I start and stop the script. Is there any way to be rid if that?

Also, parec does not record in mp3 format, but rather in raw format. One needs to pipe it through lame to get mp3 output. Here is another version of the script. The echo lines are useful if you start/stop the script from the terminal.

#!/bin/sh                                                                                                                   

if [ -n "$(ps -e | grep parec)" ]; then                                                                                     
 killall parec;                                                                                                             
 pacmd set-source-volume source.droid 65536;                                                                                
 echo -e "\033[32;1;4mrecording stopped.\033[0m"                                                                            
 exit 0;                                                                                                                    
fi                                                                                                                          

mkdir -p /home/nemo/lydfiler                                                                                                
pacmd set-source-volume source.droid 229376                                                                                 
parec | lame -r - /home/nemo/lydfiler/$(date +%d-%m-%H:%M).mp3 &                                                            
echo -e "\033[31;1;4mrecording started ...\033[0m"
mortenbo ( 2020-04-23 13:03:09 +0200 )edit

@mortenbo I noticed that too, I was able to play the file only with parec playback option again. I tried --file-format which didn't work for me. How did you install lame on SailfishOS ?

I don't have any idea about the 10 seconds delay untill the app closes itself. You could try ShellEx app which you can find in Jolla store for more instant running.

nas ( 2020-04-23 13:41:05 +0200 )edit

@nas, I believe I installed lame with devel-su pkcon install lame. If I remember incorrectly, then maybe I installed it from openrepos - there is a version of lame there in the "NielDK" repository.

mortenbo ( 2020-04-23 14:01:03 +0200 )edit
Login/Signup to Answer

Question tools

Follow
5 followers

Stats

Asked: 2020-04-09 18:41:21 +0200

Seen: 406 times

Last updated: Apr 23 '20