How to run script to update Ddog by clicking it? (Solved)

a very small Live CD shaped to look and act like Puppy Linux.

Moderator: fredx181

Post Reply
dcung
Posts: 373
Joined: Fri Sep 25, 2020 4:31 am
Has thanked: 42 times
Been thanked: 51 times

How to run script to update Ddog by clicking it? (Solved)

Post by dcung »

I created a simple script to update Ddog.

It works. But you have to either run it from a terminal or "Right click & run in terminal" to see the output in foreground.

How do I make it so that my sister can just click it and see it running (in foreground).
I think she'll forget if I tell her to 'run from terminal'.

Code: Select all

#!/bin/bash

# Filename/file location -  /mnt/sda1/MyData/customise/Update-OS
echo
echo
echo
read -sp "Updating OS. Press ENTER to continue or Ctrl-C to Cancel. . ."
echo
echo

apt update
#apt upgrade -y   #Comment out during test

echo
echo
read -sp "Update completed. Press ENTER to continue."
echo

Code: Select all

[Desktop Entry]
Version=1.0
Type=Application
Name=Update OS
Comment=
#Exec=/mnt/sda1/MyData/customise/Update-OS   #or below
Exec=xterm -e "bash -c '/mnt/sda1/MyData/customise/Update-OS'"
Icon=/root/icons/terminal.png
Path=
Terminal=true
StartupNotify=false
Categories=Application;

Sort of like what this guy is trying to do.
And the replies didn't address the question (?).
https://askubuntu.com/questions/138908/ ... in-windows
.
.

If it's too hard, I'll probably just try to teach her right-click & 'run in terminal' :)

Last edited by dcung on Tue Dec 19, 2023 9:51 pm, edited 1 time in total.
User avatar
fredx181
Posts: 2610
Joined: Tue Dec 03, 2019 1:49 pm
Location: holland
Has thanked: 284 times
Been thanked: 1018 times
Contact:

Re: Simple script - help

Post by fredx181 »

@dcung
If the purpose is to run it by 'just clicking the script', one way is to run it from xterm (if installed) with exported function run_in_xterm :
(can't see btw why the .desktop launcher code you posted won't work (it should work with Terminal=true) but perhaps better leave out the (empty) Path=)
EDIT: or perhaps better make Exec= simply Exec=/mnt/sda1/MyData/customise/Update-OS (combined with Terminal=true it should run from the default terminal)
Anyway, clickable script to run from xterm:

Code: Select all

#!/bin/bash

# function run_in_xterm
run_in_xterm () {
# Filename/file location -  /mnt/sda1/MyData/customise/Update-OS
echo
echo
echo
read -sp "Updating OS. Press ENTER to continue or Ctrl-C to Cancel. . ."
echo
echo

apt update
#apt upgrade -y   #Comment out during test

echo
echo
read -sp "Update completed. Press ENTER to continue."
echo
}
export -f run_in_xterm

# run function 'run_in_xterm' from xterm
xterm -T "Update-OS" -e /bin/bash -c run_in_xterm
dcung
Posts: 373
Joined: Fri Sep 25, 2020 4:31 am
Has thanked: 42 times
Been thanked: 51 times

Re: Simple script - help <SOLVED>

Post by dcung »

fredx181 wrote: Tue Dec 19, 2023 9:37 pm

@dcung
If the purpose is to run it by just clicking on the script, one way is to run it from xterm (if installed) with exported function run_in_xterm :
(can't see btw why the .desktop launcher code you posted won't work (it should work with Terminal=true) but perhaps better leave out the (empty) Path=)
EDIT: or perhaps better make Exec= simply Exec=/mnt/sda1/MyData/customise/Update-OS (combined with Terminal=true it should run from the default terminal)

The code you provided is exactly what I was looking for and it works. :thumbup:

I also tried the .desktop way, still didn't work.
The link I provided above also seems to suggest it should work.
But it didn't for me. Will tinker again. Not surprised if I found it was my fault later.

Post Reply

Return to “DebianDogs”