Sample Header Ad - 728x90

Unix & Linux Stack Exchange

Q&A for users of Linux, FreeBSD and other Unix-like operating systems

Latest Questions

0 votes
2 answers
7578 views
How to store and print variables with special characters in shell/bash/sh/
I basically need to load, save and reload multiple times and in different forms a variable that contains arguments for a program. The problem is that this variable can't be treated as a usual variable because it contains the "-" sign in the start. And print it or load it to be possible to see what i...
I basically need to load, save and reload multiple times and in different forms a variable that contains arguments for a program. The problem is that this variable can't be treated as a usual variable because it contains the "-" sign in the start. And print it or load it to be possible to see what it contains makes things hard due to the constant need of a \\ at the start before it can be used or not. A trick was always saved it with the \\, but before reading it, I echo $it then read the last output as a variable for the use case. This is strongly impractical, so I need a way to save the contents of a variable in a manner that will never interfere with the code that executes it. The below variable is used by yad a default for gdb, but it can be for any other program. For example, a quick test to know if a variable like that can be used in my context is trough printf **WITHOUT** the need of any printf parameter. This is because: gdbParameters="-ex 'set pagination off' -ex 'set environment G_MESSAGES_DEBUG = all'" printf $gdbParameters returns: printf: usage: printf [-v var] format [arguments] Thank you all.
DATALOT (459 rep)
Jun 20, 2020, 05:08 PM • Last activity: Mar 6, 2025, 03:51 PM
2 votes
1 answers
183 views
How to programmatically kill a notify-send window?
I have a bash script that opens a window with `notify-send`. I would like to close that window when the script ends, but I can find nothing to `kill`. The question is a duplicate of https://askubuntu.com/questions/639754/is-it-possible-to-cancel-or-clear-a-notification-created-by-using-notify-send ,...
I have a bash script that opens a window with notify-send. I would like to close that window when the script ends, but I can find nothing to kill. The question is a duplicate of https://askubuntu.com/questions/639754/is-it-possible-to-cancel-or-clear-a-notification-created-by-using-notify-send , but none of the answers work for me. The accepted answer says to kill a process called notify-osd, but I don’t have anything like that. It is noticeable that that question is ten years' old. My script is like notify-send -u critical -i ~/.icons/my-icon.png "$titletext" "$helptext" helppid=$! … kill $helppid (The urgency setting is critical so that the Help window stays open until explicitly dismissed.) The problem is that $! does not return a value. ps -ef | grep -i notify shows nothing connected to my script. I have found a work-around, using the print-id feature of notify-send (described in https://askubuntu.com/a/161852 ): print-id=$(notify-send -p -u critical -i ~/.icons/my-icon.png "$titletext" "$helptext") notify-send -r $print-id -u low ~/.icons/my-icon.png "$titletext" Finished Can anyone describe a better way to dismiss the help dialogue? I have read recommendations for yad, and wonder whether to install and evaluate it.
Peter Bill (526 rep)
Jan 8, 2025, 05:21 PM • Last activity: Jan 9, 2025, 02:49 PM
19 votes
4 answers
6209 views
Is there a command to write text to a file without redirection, pipe or function?
Pipes and redirection are two of the most powerful functions in Linux, and I love them. However, I'm stuck with a situation where I need to write a fixed piece of text to a file without using a pipe, redirection or a function. I'm using Bash in case that makes a difference. First: Why? ----------- I...
Pipes and redirection are two of the most powerful functions in Linux, and I love them. However, I'm stuck with a situation where I need to write a fixed piece of text to a file without using a pipe, redirection or a function. I'm using Bash in case that makes a difference. First: Why? ----------- I'll explain why, in case there's a simpler solution. I have a background yad notification with some menu entries. In some of the menu entries, I want the notification to write a fixed piece of text to a file. Here's an example of what I mean. yad --notification --command=quit --menu='Example!echo sample >text.txt' The problem is that yad doesn't accept redirection, so it literally prints the string sample >text.txt instead of redirecting. Likewise, the pipe symbol (|) is a separator in yad; but if you change that, yad takes it as a literal character. For example: yad --notification --command=quit --separator='#' --menu='Example!echo sample | tee text.txt' This literally prints the string sample | tee text.txt instead of piping. There's also no point in writing a function for yad to call, because yad runs in its own space and doesn't recognise the function. Hence my question ----------------- Thus, I want a command like echo, cat or printf that takes an output file as an argument rather than a redirect. I have searched for such a command but cannot find it. I can, of course, write my own and put it in the default path: FILENAME="${1}" shift printf '%s\n' "${*}" >"${FILENAME}" and then yad --notification --command=quit --menu='Example!myscript text.txt sample' But, I'll be surprised indeed if Linux doesn't already have something like this! Thank you
Paddy Landau (346 rep)
Oct 20, 2020, 01:39 PM • Last activity: Jun 7, 2024, 05:28 PM
1 votes
1 answers
1472 views
yad: how to set font size? Is there a bug?
I use yad fonts as [tag:Pango] style, like the man page required: yad --width=250 --text 'foo bar base' --fontname="Serif bold italic 90" there's no difference if I do yad --width=250 --text 'foo bar base' --fontname="Serif bold italic 10" bug or [PEBKAC](https://en.wikipedia.org/wiki/User_error#PEB...
I use yad fonts as [tag:Pango] style, like the man page required: yad --width=250 --text 'foo bar base' --fontname="Serif bold italic 90" there's no difference if I do yad --width=250 --text 'foo bar base' --fontname="Serif bold italic 10" bug or [PEBKAC](https://en.wikipedia.org/wiki/User_error#PEBKAC/PEBCAK/PICNIC) ? Modified example from doc page: http://smokey01.com/yad/ Better real test case, using trick (display the tag as is without HTML rendering): yad --no-focus --on-top --borders=10 --geometry -0+80 --height=100 --no-markup --question --title 'title' --text 'coucou\nhey\n20230228'
Mévatlavé Kraspek (541 rep)
Feb 28, 2023, 10:53 AM • Last activity: May 13, 2023, 11:45 AM
1 votes
1 answers
291 views
Check which entry is empty with yad or zenity
I'm trying to create an array of four elements using a form consisting of 4 entries: new_prop=($(zenity --forms --title="my-script" --text="Insert the values" --separator=" " \ --add-entry="Name" \ --add-entry="Surname" \ --add-entry="Gender" \ --add-entry="Age")) In general, the user can leave the...
I'm trying to create an array of four elements using a form consisting of 4 entries: new_prop=($(zenity --forms --title="my-script" --text="Insert the values" --separator=" " \ --add-entry="Name" \ --add-entry="Surname" \ --add-entry="Gender" \ --add-entry="Age")) In general, the user can leave the Gender field empty, but the other 3 must be filled. The problem is that zenity (I don't know yad) doesn't create an empty element if an entry is left empty, but simply it skips that element. For example, if I insert Name and Age, zenity makes an array new_prop of 2 elements. How can I check if an entry in the form is left empty? It doesn't matter if the form is made with zenity or yad. Thank you!
user9952796 (81 rep)
May 3, 2023, 03:01 PM • Last activity: May 4, 2023, 10:07 AM
1 votes
1 answers
2808 views
Yad: text selection via button OR input field
i want to create a yad command which displays 1 button and 1 input field. I want that when the user clicks on the button a predefined text is returned to stdout. And when the user writes something into the input field and presses enter/clicks on another button, then the input field text is returned...
i want to create a yad command which displays 1 button and 1 input field. I want that when the user clicks on the button a predefined text is returned to stdout. And when the user writes something into the input field and presses enter/clicks on another button, then the input field text is returned to stdout instead. How would you do something like that?
Loading (113 rep)
Jan 9, 2022, 09:59 PM • Last activity: Jan 10, 2022, 01:02 AM
1 votes
0 answers
828 views
Problem with yad and variable's spaces its arguments
My code works with: ``` binariesPathList="FALSE 'inkscape' TRUE '/home/jeanfar/Downloads/binary-portable/inkscape/Inkscape-1.0-4035a4f-x86_64.AppImage' FALSE '/home/jeanfar/Downloads/binary-portable/inkscape/Inkscape-f54ab5f-x86_64.AppImage' FALSE '/home/jeanfar/git-clones/inkscape-0.92.5/build/inst...
My code works with:
binariesPathList="FALSE 'inkscape'
TRUE '/home/jeanfar/Downloads/binary-portable/inkscape/Inkscape-1.0-4035a4f-x86_64.AppImage'
FALSE '/home/jeanfar/Downloads/binary-portable/inkscape/Inkscape-f54ab5f-x86_64.AppImage'
FALSE '/home/jeanfar/git-clones/inkscape-0.92.5/build/install_dir/bin/inkscape'
FALSE '/home/jeanfar/git-clones/inkscape/build/install_dir/bin/inkscape'"

# This is to demonstrate how YAD will receive it. 
echo $binariesPathList

answer=$(yad \
    --list \
    --radiolist \
        --column="Pick" \
        --column="Application" \
        --column="Application Path" \
        $binariesPathList \
)
If you run that last code (Ignore buttons): enter image description here But fails with the exact same configuration, but three columns. If you run it, you will note that even with the same ' sign, it split by spaces.
binariesPathList="FALSE 'System Default Installation' 'inkscape'
TRUE '1.0 AppImage' '/home/jeanfar/Downloads/binary-portable/inkscape/Inkscape-1.0-4035a4f-x86_64.AppImage'
FALSE '1.1-dev Appimage' '/home/jeanfar/Downloads/binary-portable/inkscape/Inkscape-f54ab5f-x86_64.AppImage'
FALSE '0.92.5 Build' '/home/jeanfar/git-clones/inkscape-0.92.5/build/install_dir/bin/inkscape'
FALSE 'Master Build' '/home/jeanfar/git-clones/inkscape/build/install_dir/bin/inkscape'"

# This is to demonstrate how YAD will receive it. 
echo $binariesPathList

answer=$(yad \
    --list \
    --radiolist \
        --column="Pick" \
        --column="Application" \
        --column="Application Path" \
        $binariesPathList \
)
If you run that last code (Ignore buttons): enter image description here The really strange thing here is that you can put the parameters directly where the variable should be, and it will work even better than first, and even with those spaces. It's exactly as a copy-paste of the echo, but if you replace the variable with $(echo $binariesPathList) it will be the same result.
answer=$(yad \
    --list \
    --radiolist \
        --column="Pick" \
        --column="Application" \
        --column="Application Path" \
        FALSE 'System Default Installation' 'inkscape' FALSE '1.0 AppImage' '/home/jeanfar/Downloads/binary-portable/inkscape/Inkscape-1.0-4035a4f-x86_64.AppImage' FALSE '1.1-dev Appimage' '/home/jeanfar/Downloads/binary-portable/inkscape/Inkscape-f54ab5f-x86_64.AppImage' FALSE '0.92.5 Build' '/home/jeanfar/git-clones/inkscape-0.92.5/build/install_dir/bin/inkscape' FALSE 'Master Build' '/home/jeanfar/git-clones/inkscape/build/install_dir/bin/inkscape' \
)
If you run that last code: enter image description here
DATALOT (459 rep)
Jun 21, 2020, 08:00 AM • Last activity: Jun 21, 2020, 08:17 AM
0 votes
2 answers
1204 views
parsing variable which contains vertical bar
I have a bash script that involves the output of `yad`. By default, `yad` outputs its results separated by pipe characters "`|`". I have a string variable `output`. Echoing it shows it contains this: /dev/sde| name0|name1|name2| I want all those vertical bars changed to line breaks. This does not wo...
I have a bash script that involves the output of yad. By default, yad outputs its results separated by pipe characters "|". I have a string variable output. Echoing it shows it contains this: /dev/sde| name0|name1|name2| I want all those vertical bars changed to line breaks. This does not work: echo "$output" | tr '|' '\n' And neither does this: echo "$output" > /tmp/output; echo $(cut -d'|' -f1 < /tmp/output) Both attempts result in only a line break being outputted. /tmp/output was created, and it contained two empty lines but not any text.
Botspot (161 rep)
Feb 11, 2020, 01:40 PM • Last activity: Feb 11, 2020, 07:27 PM
0 votes
1 answers
1430 views
About ||||| (pipe or vertical bars) In yad --form --button
During Working with yad --form displayed some |||(vertical bars) after clicked a button, what are this bars indicating & how I can STOP them to display? Providing sample code, You can experience yad --width=400 --height=200 --button="gtk-ok" --form --field="Click Down":LBL "echo Clicked" --field="Cl...
During Working with yad --form displayed some |||(vertical bars) after clicked a button, what are this bars indicating & how I can STOP them to display? Providing sample code, You can experience yad --width=400 --height=200 --button="gtk-ok" --form --field="Click Down":LBL "echo Clicked" --field="Click HERE":BTN Result output will be " **Clicked** *then* **||**
AlphaCoder (173 rep)
Jan 5, 2019, 08:08 AM • Last activity: Jan 5, 2019, 12:32 PM
0 votes
1 answers
944 views
how to make a Yad split window, upper split = text and lower split = progress bar?
I can't work out how to make a Yad split window, upper split = text and lower split = progress bar? My attempt below failed. id=$(echo $[($RANDOM % ($[10000 - 32000] + 1)) + 10000] ) Settings=$(cat ~/tmp/YadWindow4SelectedSettings.txt) { echo 25 echo "#25%" echo 50 echo "#50%" echo 75 echo "#75%" ec...
I can't work out how to make a Yad split window, upper split = text and lower split = progress bar? My attempt below failed. id=$(echo $[($RANDOM % ($[10000 - 32000] + 1)) + 10000] ) Settings=$(cat ~/tmp/YadWindow4SelectedSettings.txt) { echo 25 echo "#25%" echo 50 echo "#50%" echo 75 echo "#75%" echo 100 echo "#100%" } | yad --plug=$id --tabnum=1 --progress --auto-close --auto-kill --center --width=700 --image=$ICON --image-on-top --title="Loading..." --percentage=0 &> res1 & yad --plug=$id --tabnum=2 --text="$Settings" &> res2 & yad --length=800 --width=800 --center --paned --key=$id --splitter="200"
Giles (897 rep)
Apr 28, 2017, 11:40 PM • Last activity: Nov 17, 2018, 12:17 AM
1 votes
1 answers
1570 views
Redirect YAD results into file AND still give exit codes from buttons to STDOUT
I have 2 custom buttons in my yad --form. The user input aka results get redirected into a .txt file for later use. Thats working fine. But it seems like the exit code is not given to STDOUT anymore, when I'm redirecting in this way. But I need the exit code to decide how to move on, of course. Am I...
I have 2 custom buttons in my yad --form. The user input aka results get redirected into a .txt file for later use. Thats working fine. But it seems like the exit code is not given to STDOUT anymore, when I'm redirecting in this way. But I need the exit code to decide how to move on, of course. Am I on the right path here? Is there another solution that still delivers the exit codes to STDOUT? yad --title="egPorSS - TYPO3 Constants Setup" --center --borders="20" --width="500" --separator="\n" 2> /dev/null \ --form \ --field="egON API-Key":TEXT \ --field="Host for AJAX-Requests":TEXT \ --field="SOAP-Username":TEXT \ --field="SOAP-Password":TEXT \ --field="SOAP-URL:":TEXT \ --field="SEPA-Service":CHK \ --field="Base-Provider":CHK \ --field="Digital Signature":CHK \ --field="Company name":TEXT \ --field="Street, Number":TEXT \ --field="City":TEXT \ --button="Discard entries":1 \ --button="Write to DB":0 > ./temp/constants_modified.txt # Write entries to .txt file. # if Button "Write to DB" is pressed, ask again, before manipulating DB if [ $? -eq 0 ]; then yad --title="egPorSS - TYPO3 Constants Setup" --center --borders="20" 2> /dev/null \ --text="Write changes to constants field in ${DB} now?" \ --button="No, discard":0 \ --button="Yes, write":1 # if "Yes, write" => modify ./temp/constants_${DB}.typoscript" and coll pushConstantsDB() if [ $? -eq 1 ]; then sed -i "s/plugin.tx_egon_pi1.system.apiKey.*/plugin.tx_egon_pi1.system.apiKey = ${modified}/" ${typoscript} sed -i "s/plugin.tx_egon_pi1.system.host.*/plugin.tx_egon_pi1.system.host = ${modified}/" ${typoscript} sed -i "s/plugin.tx_egon_pi1.soap.user.*/plugin.tx_egon_pi1.soap.user = ${modified}/" ${typoscript} sed -i "s/plugin.tx_egon_pi1.soap.password.*/plugin.tx_egon_pi1.soap.password = ${modified}/" ${typoscript} sed -i "s/plugin.tx_egon_pi1.soap.url.*/plugin.tx_egon_pi1.soap.url = ${modified}/" ${typoscript} sed -i "s/plugin.tx_egon_pi1.settings.useSEPA.*/plugin.tx_egon_pi1.settings.useSEPA = ${modified}/" ${typoscript} sed -i "s/plugin.tx_egon_pi1.settings.useBaseProvider.*/plugin.tx_egon_pi1.settings.useBaseProvider = ${modified}/" ${typoscript} sed -i "s/plugin.tx_egon_pi1.settings.signatureAllowed.*/plugin.tx_egon_pi1.settings.signatureAllowed = ${modified}/" ${typoscript} sed -i "s/plugin.tx_egon_pi1.custom.companyName.*/plugin.tx_egon_pi1.custom.companyName = ${modified}/" ${typoscript} sed -i "s/plugin.tx_egon_pi1.custom.companyStreet.*/plugin.tx_egon_pi1.custom.companyStreet = ${modified}/" ${typoscript} sed -i "s/plugin.tx_egon_pi1.custom.companyCity.*/plugin.tx_egon_pi1.custom.companyCity = ${modified}/" ${typoscript} echo -e "${LIBLUE}Writing changes to Database now.. ${NF}\n" pushConstantsDB else echo -e "${LIBLUE}Returning to main menu without any changes.. ${NF}" sleep 6 fi else echo -e "${LIBLUE}Returning to main menu without any changes.. ${NF}" sleep 6 fi
Wu Wei (113 rep)
Aug 14, 2018, 03:11 PM • Last activity: Oct 16, 2018, 03:24 PM
2 votes
1 answers
3033 views
yad, how to create a simple question dialog?
I know yad can do much more than zenity, but it also misses quickies like `--question`. What is the simplest way to mimic that zenity option on yad? Obs.: mimic quickies for other possibly missing options are much welcome! *NOT REQUIRED:* As an opinion based answer bonus request, I would like to kno...
I know yad can do much more than zenity, but it also misses quickies like --question. What is the simplest way to mimic that zenity option on yad? Obs.: mimic quickies for other possibly missing options are much welcome! *NOT REQUIRED:* As an opinion based answer bonus request, I would like to know if yad may resist the time, in a sense that zenity may last longer? I really want to implement scripts based on yad, but I would like to have an idea if it will still be maintained after 5 or 10 years? It seems that, ubuntu ppa at least, has auto-compile so packages may be auto-cooked fresh, is that also true? So basically, should I create something intermediary, where it will pop the dialog in yad or zenity (with severe functionalities limitations)?
Aquarius Power (4537 rep)
Mar 3, 2016, 09:39 PM • Last activity: Dec 21, 2017, 03:01 PM
0 votes
1 answers
1039 views
Yad forking and return results
I'm trying to make a yad process collaborate with another (a mounter but that's not very important). I have a code structure like this (simplified) in the critical part: ` yad --list --button=gtk-close:1 --button=gtk-ok:0 "${CONF_LIST[@]}" 2>/dev/null & yad_pid=$! #3 is the file descriptor of the na...
I'm trying to make a yad process collaborate with another (a mounter but that's not very important). I have a code structure like this (simplified) in the critical part: ` yad --list --button=gtk-close:1 --button=gtk-ok:0 "${CONF_LIST[@]}" 2>/dev/null & yad_pid=$! #3 is the file descriptor of the named pipe of the other process { read -u 3 line && kill -USR2 $yad_pid 2>/dev/null; } & pidof_killer=$! wait $yad_pid result=$? kill $pidof_killer 2>/dev/null #do something with result. My problem here is that part of what i need (besides the result) is the list selection. Previously to being a fork, i could just do VAR=$(yad ...) and get it in addition to the yad exit code, but now i don't know how to communicate it to the main process after the wait.
i30817 (197 rep)
Jul 1, 2017, 09:15 AM • Last activity: Jul 1, 2017, 12:02 PM
1 votes
1 answers
167 views
Output NamingVariable for Multiple Files in Bash Script
I have a script I've created that will pad a series of Jpgs, create a subdirectory in the working directory, move the padded Jpgs to the subdirectory, change to the subdirectory, and then use Imagemagick's convert command to overlay a single transparent .gif over the padded images. All but the last...
I have a script I've created that will pad a series of Jpgs, create a subdirectory in the working directory, move the padded Jpgs to the subdirectory, change to the subdirectory, and then use Imagemagick's convert command to overlay a single transparent .gif over the padded images. All but the last step works. If I run this script on one Jpg file it works correctly. But when I try it on multiple Jpgs it will only semi-work on one Jpg and not the others. I assume that I'm not using the correct naming variable in the last command, but I'm having no luck finding the correction. Bash script: #!/bin/bash if yad \ --image "dialog-question" \ --title "Alert" \ --button=gtk-yes:0 \ --button=gtk-no:1 \ --text "Have you resized JPGs?" then convert *.jpg "$i" -bordercolor black -border 120x0 "pad$i.jpg" mkdir -p ./padded; mv pad*.jpg $_ cd padded cp /home/mastergif/ggg.gif /home/test/padded convert ggg.gif *.jpg "$i" -background black -gravity center -compose dstover -composite $i*.jpg exec bash else exit 1 fi
whitewings (2527 rep)
Mar 25, 2016, 06:27 AM • Last activity: Sep 2, 2016, 06:19 PM
Showing page 1 of 14 total questions