You are not logged in.

#1 2016-05-24 05:42:19

kleiner_hussar
Member
From: Traunstein, Germany
Registered: 2016-04-25
Posts: 82

The great yad hacking thread

1

Last edited by kleiner_hussar (2016-06-02 10:40:50)

Offline

#2 2016-05-24 05:56:40

damo
....moderator....
Registered: 2015-08-20
Posts: 6,734

Re: The great yad hacking thread

Cheeky boy - you've been peeking in my github repo big_smile

Good idea for a thread though. Tutorials and examples for yad, which are much use, are hard to find (although the yad wiki now has a lot more examples). I've spent hours trawling through a google group thread, which seemed to be the main "resource" for answers to problems.


Be Excellent to Each Other...
The Bunsenlabs Lithium Desktop » Here
FORUM RULES and posting guidelines «» Help page for forum post formatting
Artwork on DeviantArt  «» BunsenLabs on DeviantArt

Offline

#3 2016-05-24 06:16:34

kleiner_hussar
Member
From: Traunstein, Germany
Registered: 2016-04-25
Posts: 82

Re: The great yad hacking thread

2

Last edited by kleiner_hussar (2016-06-02 10:41:02)

Offline

#4 2016-05-24 10:41:19

kleiner_hussar
Member
From: Traunstein, Germany
Registered: 2016-04-25
Posts: 82

Re: The great yad hacking thread

3

Last edited by kleiner_hussar (2016-06-02 10:41:14)

Offline

#5 2016-05-24 11:39:51

Naik
Member
From: the edge of insanity
Registered: 2015-10-03
Posts: 328

Re: The great yad hacking thread

Hey this is really cool!

I tried to get the radio working immediately but running it from cli it looks like this

naik@HP-D2:~$ sh ~/scripts/radio
Gtk-Message: GtkDialog mapped without a transient parent. This is discouraged.
/home/naik/scripts/radio: 39: /home/naik/scripts/radio: [[: not found
/home/naik/scripts/radio: 41: /home/naik/scripts/radio: [[: not found
/home/naik/scripts/radio: 46: /home/naik/scripts/radio: [[: not found

[httpget.c:172] error: Error reading from socket or unexpected EOF.

[httpget.c:640] error: readstring failed

[mpg123.c:611] error: Access to http resource http://swr-mp3-s-swr1bw.akacast.akamaistream.net/7/395/137133/v1/gnl.akacast.akamaistream.net/swr-mp3-s-swr1bw failed.

running it using the mocp server works just fine though it is not shown in my mocp related conky section for any reason.
can you maybe help me to fix at last one of this problems so i can listen to the radio without being annoyed by this minor troubles?


"Kaum macht [Mensch]* es richtig, funktioniert es sofort!"
BL-Kitchen Codeberg

Offline

#6 2016-05-24 11:45:05

xaos52
The Good Doctor
From: Planet of the @pes
Registered: 2015-09-30
Posts: 695

Re: The great yad hacking thread

Use 'bash' to launch the script in stead of 'sh'
[[ is a bashism

Offline

#7 2016-05-24 11:57:44

kleiner_hussar
Member
From: Traunstein, Germany
Registered: 2016-04-25
Posts: 82

Re: The great yad hacking thread

4

Last edited by kleiner_hussar (2016-06-02 10:41:27)

Offline

#8 2016-05-24 12:41:02

Naik
Member
From: the edge of insanity
Registered: 2015-10-03
Posts: 328

Re: The great yad hacking thread

kleiner_Husar wrote:

Run the script as an application

Thats what i did. I just checked back, when nothing happend after clicking "ok". Things work quiet well now. As it seems most of the links won`t work, which is sad but i`ll try to get back with an updated copy of the script..
Great work anyways. I realy like it a lot!

...und danke für den Hinweis auf yad, das hab ich bisher noch gar nicht so richtig wahr genommen.

naik --greetz


"Kaum macht [Mensch]* es richtig, funktioniert es sofort!"
BL-Kitchen Codeberg

Offline

#9 2016-05-24 12:49:16

kleiner_hussar
Member
From: Traunstein, Germany
Registered: 2016-04-25
Posts: 82

Re: The great yad hacking thread

5

Last edited by kleiner_hussar (2016-06-02 10:41:39)

Offline

#10 2016-05-24 18:04:17

kleiner_hussar
Member
From: Traunstein, Germany
Registered: 2016-04-25
Posts: 82

Re: The great yad hacking thread

6

Last edited by kleiner_hussar (2016-06-02 10:41:50)

Offline

#11 2016-05-24 19:42:46

damo
....moderator....
Registered: 2015-08-20
Posts: 6,734

Re: The great yad hacking thread

Helper functions for BunsenLabs yad scripts

For BunsenLabs yad scripts, @johnraff has included a time-saver 'includes' file, which has several yad utility functions. Add this at the beginning of a script which uses yad, to source them:

BL_COMMON_LIBDIR='/usr/lib/bunsen/common'

if ! . "$BL_COMMON_LIBDIR/yad-includes" 2> /dev/null; then
    echo "Error: Failed to source yad-includes in $BL_COMMON_LIBDIR" >&2
    exit 1
fi

The 'yad-includes' file has the following Help comments:

# These are global options for all the yad functions defined below.
# You can add to them for the duration of your script with something like:
# yad_common_args+=(--image=debian)
# Override options already set with, eg:
# yad_common_args+=(--borders=30)
# Unset options with 0, eg:
# yad_common_args+=(--center=0)

yad_common_args=('--window-icon=distributor-logo-bunsenlabs' '--center' '--borders=20')
yad_popup_args=('--undecorated' '--fixed' '--on-top')

# Call these functions as shorthand for simple popups etc.
# Append any options you want to add, change or unset.
# Plain strings will be regarded as --text eg:
# yad_info "It's not as bad as you think."
# Buttons are identified by their return values
# so their labels can be changed, eg:
# yad_error 'Something went wrong.' --button='Resigned acceptance':0
# New buttons will be added on the right, eg:
# yad_question 'Continue?' --button='Tell me more':2

Be Excellent to Each Other...
The Bunsenlabs Lithium Desktop » Here
FORUM RULES and posting guidelines «» Help page for forum post formatting
Artwork on DeviantArt  «» BunsenLabs on DeviantArt

Offline

#12 2016-05-25 06:31:47

kleiner_hussar
Member
From: Traunstein, Germany
Registered: 2016-04-25
Posts: 82

Re: The great yad hacking thread

6

Last edited by kleiner_hussar (2016-06-02 10:42:06)

Offline

#13 2016-05-25 10:19:01

kleiner_hussar
Member
From: Traunstein, Germany
Registered: 2016-04-25
Posts: 82

Re: The great yad hacking thread

7

Last edited by kleiner_hussar (2016-06-02 10:42:22)

Offline

#14 2016-05-25 10:33:39

kleiner_hussar
Member
From: Traunstein, Germany
Registered: 2016-04-25
Posts: 82

Re: The great yad hacking thread

8

Last edited by kleiner_hussar (2016-06-02 10:42:32)

Offline

#15 2016-05-25 18:32:00

damo
....moderator....
Registered: 2015-08-20
Posts: 6,734

Re: The great yad hacking thread

Problem with yad --progress sad

I am re-writing my youtube-dl wrapper script and have run into an issue with the progress window. "--auto-kill" should kill the parent process if the Cancel button is pressed, and I want to use this to clean up the .part file if the download is interrupted, by using the $PIPESTATUS shell var.

.....
# Run youtube download, pipe to progress dialog
youtube-dl -i -o "$SAVEDIR/%(id)s.%(ext)s" $URL | yad --progress --pulsate \
            --progress-text="" \
            --auto-kill --auto-close \
            --window-icon=distributor-logo-bunsenlabs --borders=10 \
            --center --undecorated --text="Youtube downloader:
.....

Raw script: https://raw.githubusercontent.com/capn- … er/youtube

However the Cancel button is ineffective (and the window is blocked until the download completes), as soon as the .part file starts to be written. I presume that a second youtube-dl process starts when the data is being written, and the first one waits until it completes.

Any clever people know how to troubleshoot this?


Be Excellent to Each Other...
The Bunsenlabs Lithium Desktop » Here
FORUM RULES and posting guidelines «» Help page for forum post formatting
Artwork on DeviantArt  «» BunsenLabs on DeviantArt

Offline

#16 2016-05-25 19:20:49

damo
....moderator....
Registered: 2015-08-20
Posts: 6,734

Re: The great yad hacking thread

^ Exact same behaviour I'm afraid sad


Be Excellent to Each Other...
The Bunsenlabs Lithium Desktop » Here
FORUM RULES and posting guidelines «» Help page for forum post formatting
Artwork on DeviantArt  «» BunsenLabs on DeviantArt

Offline

#17 2016-05-25 19:57:29

kleiner_hussar
Member
From: Traunstein, Germany
Registered: 2016-04-25
Posts: 82

Re: The great yad hacking thread

9

Last edited by kleiner_hussar (2016-06-02 10:42:44)

Offline

#18 2016-05-25 20:20:32

damo
....moderator....
Registered: 2015-08-20
Posts: 6,734

Re: The great yad hacking thread

Thanks for trying this. With your code I'm still getting a non-responsive dialog once the .part file has started to be written.

My first script had a progress function, which was completely separate from the youtube-dl process. Piping a command to the progress dialog is a lot more elegant, but obviously it is depending on the behaviour of the command.

Maybe I'll go back to my first approach hmm

BTW For numerical testing my understanding is that it is recommended to use the "((...))" syntax

(( $ret == 1 ))

Be Excellent to Each Other...
The Bunsenlabs Lithium Desktop » Here
FORUM RULES and posting guidelines «» Help page for forum post formatting
Artwork on DeviantArt  «» BunsenLabs on DeviantArt

Offline

#19 2016-05-26 03:42:02

johnraff
nullglob
From: Nagoya, Japan
Registered: 2015-09-09
Posts: 12,557
Website

Re: The great yad hacking thread

kleiner_hussar wrote:

I thought I figured it out (=the yad includes), but not. Grrr

Try it in a terminal first. Just run

. /usr/lib/bunsen/common/yad-includes

then try a simple dialog like

yad_info

and see if the window comes up. Then you can try out the different options and figure out where the problems were.

And see /usr/bin/bl-dropbox-pipemenu for some working examples.

Last edited by johnraff (2016-05-26 03:44:26)


...elevator in the Brain Hotel, broken down but just as well...
( a boring Japan blog (currently paused), now on Bluesky, there's also some GitStuff )

Introduction to the Bunsenlabs Boron Desktop

Offline

#20 2016-05-26 04:58:20

kleiner_hussar
Member
From: Traunstein, Germany
Registered: 2016-04-25
Posts: 82

Re: The great yad hacking thread

9

Last edited by kleiner_hussar (2016-06-02 10:42:56)

Offline

Board footer

Powered by FluxBB