1

This is related with Execute sh script from *.desktop file? but here the OP asks how to call a bash script from an icon.

I want to write a shell script that is called from an icon and return the name of a file (in this case a .xlsx). In a webserver I would just return the correct mime type but I have no idea of what I need to do in the GNOME context.

My script would be something like

#!/bin/bash

X=$(ls -tr /mydatadir/myfile-* | tail -1)
echo $X

Thanks in advance.

This works, but not in the way I want. Here I'm calling the program that handles myfile directly from the script. I want the script to find out the name, return it to Gnome and let Gnome handle it. It's like when you have a script on a webserver when you return the mime type for something like a GIF and then return the data, and the browser knows how to make that look like a picture. It must (I think) be possible to do something like that with the Gnome desktop.

file: ~/Desktop/myfile.desktop

[Desktop Entry]
Name=Last Myfile
Comment=Open Last Myfile version
Icon=/usr/share/icons/Adwaita/32x32/mimetypes/x-office-spreadsheet.png
Exec=/home/myself/bin/last_myfile.sh
Type=Application
Terminal=false
Encoding=UTF-8
Categories=System;

file: /home/myself/bin/last_myfile.sh

#!/bin/bash

DIR="/home/myself/CLIENT/myfile"

X=$(ls -tr $DIR | tail -1)
nohup /usr/lib64/libreoffice/program/oosplash --calc file://$DIR/$X &
ocsav
  • 11

0 Answers0