Very nice, and nicely coded. I just added a bit of eye candy.
![Smile :)](./images/smilies/icon_smile.gif)
With kind regards,
vovchik
Vovchik, it looks great.vovchik wrote:Dear Misko,
Very nice, and nicely coded. I just added a bit of eye candy.
With kind regards,
vovchik
Code: Select all
# Yad gui file selector
# put in .bashrc and call with ctrl+g from terminal
select_files() {
local file files i IFS=' '
local -n l=READLINE_LINE p=READLINE_POINT
while IFS= read -rd '' file; do printf -v 'files[i++]' %q "$file"
done < <(yad --file --multiple --width=600 --height=600 --center | tr '|\n' '\0\0')
files="${files[*]}" l=${l:0:p}$files${l:p} p=$((p+${#files}));
}
bind -x '"\C-g":select_files'
Code: Select all
sh: syntax error near unexpected token `<'
Code: Select all
# bash --version
GNU bash, version 4.3.42(1)-release (x86_64-unknown-linux-gnu)
Even without looking into the script the error message is obvious: "<(" would be a bash process substitution which is not available when you invoke bash in POSIX mode. i.e. with a #!/bin/sh shebang.step wrote:My bash shell returns an error when parsing Misko's script - but I can't find a syntax error anywhere in it. Anyone with the same problem?That's the "<" before "<("Code: Select all
sh: syntax error near unexpected token `<'
Thanks MochiMoppel. Actually, I was pasting the code directly into terminal, so there was no shebang involved. But I'm pretty sure you hit the nail on its head. There are other ways to enable POSIX mode, so I'll check my setup to ensure that POSIX is disabled.MochiMoppel wrote:pocess substitution which is not available when you invoke bash in POSIX mode. i.e. with a #!/bin/sh shebang.
Use #!/bin/bash instead.
Code: Select all
INIT_DIR="$(pwd)"
RET_DIR=$(yad --center --borders=6 --title "dircrypt - Select encrypted directory" \
--file --directory --width=600 --height=400 --filename="$INIT_DIR/")
Code: Select all
yad --version
0.38.1 (GTK+ 2.24.30)
Code: Select all
yad --version
0.36.3 (GTK+ 2.24.23)
Code: Select all
INIT_DIR="$(pwd)"
RET_DIR=$(yad --center --borders=6 --title "dircrypt - Select encrypted directory" \
--button="gtk-ok:0" --button="gtk-cancel:1" --file --directory --width=600 --height=400 --filename="$INIT_DIR/")
[[ $? -eq 0 ]] && SOME_ACTION
[[ $? -eq 1 ]] && SOME_OTHER_ACTION
Code: Select all
yad --version
0.38.1 (GTK+ 2.24.30)
Usinggyro wrote:It all seems to work fine except when I use the "Create Folder" button. After typing in the name of the new folder I hit the "Enter" key, and nothing happens.
Code: Select all
yad --version
0.36.3 (GTK+ 2.24.30)
I'm most likely getting it wrong on what you want to do.gyro wrote:@Geoffrey and seaside,Usinggyro wrote:It all seems to work fine except when I use the "Create Folder" button. After typing in the name of the new folder I hit the "Enter" key, and nothing happens.The "Enter" key does what I expect. It causes the new directory to be accepted and it gets opened.Code: Select all
yad --version 0.36.3 (GTK+ 2.24.30)
So the remaining question is, do any of the versions between 0.36.3 and 0.38.1 function "correctly"?
gyro
Code: Select all
INIT_DIR="$(pwd)"
RET_DIR=$(yad --center --borders=6 --title "dircrypt - Select encrypted directory" \
--file --directory --width=600 --height=400 --filename="$INIT_DIR/")
echo $RET_DIR
Unfortunately, sort of yes.Geoffrey wrote:I'm most likely getting it wrong on what you want to do.
Yes, https://groups.google.com/forum/#!forum/yad-commongyro wrote:So the YAD tip is: avoid version 0.38.1
YAD 0.38.2 released
This is a bugfix release. One serious bug was fixed, update is highly recommended
Changes in this release:
- fix enter behavior
Thanks for this example, I find such a column of buttons quite useful as a kind of menu with each button executing a corresponding script.Geoffrey wrote:Buttons in --form --field are the width of the windowCode: Select all
yad --form --field="test1:FBTN" "yad --text='test1'" \ --field="test2:FBTN" "yad --text='test2'" \ --field="test3:FBTN" "yad --text='test3'"
Code: Select all
#!/bin/bash
function CLOSE_EXIT()
{
echo "Close and exit..."
kill -s SIGUSR1 $YAD_PID
} ; export -f CLOSE_EXIT
yad --text "<b>Simple Dialog</b>" --button="OK:bash -c CLOSE_EXIT"