XZM module creation

Non release banter
User avatar
Rava
Contributor
Contributor
Posts: 5424
Joined: 11 Jan 2011, 02:46
Distribution: XFCE 5.01 x86_64 + 4.0 i586
Location: Forests of Germany

XZM module creation

Post#16 by Rava » 28 Nov 2023, 16:21

Vic wrote:
28 Nov 2023, 04:20
When does a "one liner" need to become more lines?
When keeping it bug free is too bothersome.
You can make a script and call that script via the Exec= line.

During creation of a script you could add

Code: Select all

echo 'DEBUG $variable1='$variable1 
to check if variables have the correct content at this line in your script.

Vic
Samurai
Samurai
Posts: 171
Joined: 10 Aug 2016, 05:36
Distribution: Porteux V-0.1 64 KDE
Location: Utopia in Tampa, Florida, USA

XZM module creation

Post#17 by Vic » 29 Nov 2023, 23:17

Ok Rava,

I did some rearranging and am happy with the outcome.

This is the .Desktop file in the service menu folder --

Code: Select all

[Desktop Action 1]
Name=XZM-2-PORTEUX-OPTIONAL-SH-2
Icon=password-copy
Exec=file=%f; mkdir /mnt/nvme0n1p3/porteux/optional/VIC && cd /mnt/nvme0n1p3/porteux/optional/VIC && tar cf %f.tgz %f && tar -xf %f.tgz && rm %f.tgz && /mnt/nvme0n1p3/porteux/X-ON-DEMAND/1-SYSTEM-STUFF/XZM-CREATION/TWO-CLICK-CREATE-XZM/INFO/RAVA-ONE-LINER/ONE-LINER-PLUS.sh
Instead of starting out using the Desktop as the working directory I am now in porteux/optional.

I could not figure out how to make file=%f; work in the script so for now it is where it started, along with the tar stuff which also references it.

Everything else is in the .sh file in the porteux folder. That file looks like this --

Code: Select all

#!/bin/bash

/opt/porteux-scripts/dir2xzm /mnt/nvme0n1p3/porteux/optional/VIC
mv /mnt/nvme0n1p3/porteux/optional/VIC/VIC.xzm /mnt/nvme0n1p3/porteux/optional/VIC-$(date +%y-W%W-%e_%H-%M-%S-%b).xzm
rm -rf yes /mnt/nvme0n1p3/porteux/optional/VIC
dolphin /mnt/nvme0n1p3/porteux/optional
I added the last bit with dolphin opening the optional folder. If this is used with another DE it will not work.

The script is certainly easier to view and manipulate than the "one liner" in the .desktop file. Thanks for the suggestion.

I have not tried the debug stuff yet. Saving that adventure for later.

Vic

User avatar
Rava
Contributor
Contributor
Posts: 5424
Joined: 11 Jan 2011, 02:46
Distribution: XFCE 5.01 x86_64 + 4.0 i586
Location: Forests of Germany

XZM module creation

Post#18 by Rava » 30 Nov 2023, 04:25

Vic wrote:
29 Nov 2023, 23:17
I could not figure out how to make file=%f; work in the script
This is a syntax the .desktop files use.

Scripts use parameters instead.

Have some initial help on that.

https://linuxhandbook.com/bash-arguments/
Bash Beginner Tutorials
Passing Arguments to Bash Scripts

In the third part of the Bash Beginner Series, you'll learn to pass arguments to a bash shell script. You'll also learn about special bash shell variables.

Arguments can be useful, especially with Bash!

So far, you have learned how to use variables to make your bash scripts dynamic and generic, so it is responsive to various data and different user input.

In this tutorial, you will learn how you can pass variables to a bash scripts from the command line.
[…]
https://www.baeldung.com/linux/pass-com ... ash-script
1. Overview

Linux has a rich and powerful set of ways to supply parameters to bash scripts.

In this tutorial, we’ll look at a few ways of doing this.
2. Argument List

Arguments can be passed to a bash script during the time of its execution, as a list, separated by space following the script filename. This comes in handy when a script has to perform different functions depending on the values of the input.

For instance, let’s pass a couple of parameters to our script start.sh:

sh start.sh development 100
[…]
https://www.baeldung.com/linux/use-comm ... ash-script
1. Introduction

We’ve previously examined how to pass command-line arguments to a bash script. In this tutorial, we’ll take a look at how we can use these arguments inside the bash script.
[…]
And much more via this search:
https://duckduckgo.com/?q=linux+shell+s ... ter&ia=web

Post Reply