You are not logged in.

#51 2017-08-05 10:49:36

damo
....moderator....
Registered: 2015-08-20
Posts: 4,169

Re: The great yad hacking thread

martix wrote:
misko_2083 wrote:

Currently trying to make a UI for PMRP - Poor Man's Radio Player

I just gave it a try and it's way too cool!  cool    ...

Absolutely! Trying it out now wink


Be Excellent to Each Other...

FORUM RULES and posting guidelines «» Help page for forum post formatting
Artwork on DeviantArt  «» BunsenLabs on DeviantArt

Offline

#52 2017-08-05 15:14:45

martix
Kim Jong-un Stunt Double
Registered: 2016-02-19
Posts: 1,262

Re: The great yad hacking thread

@misko_2083  Do you have maybe an idea why I can start pmrp via terminal and load the stations but: Putting pmrp in ~/bin makes it available via gmrun (by running "pmrp") but I cannot load the stations that way?

I also made a pmrp.desktop file in /usr/share/applications with

[Desktop Entry]
Name=Poor Man's Radio Player
Exec=pmrp
Terminal=false
Type=Application
Icon=radio
Categories=Player;Audio;AudioVideo;

EDIT: ...and it does show up now in the (dynamic) menu structure.

Last edited by martix (2017-08-05 15:47:19)

Offline

#53 2017-08-05 15:42:40

damo
....moderator....
Registered: 2015-08-20
Posts: 4,169

Re: The great yad hacking thread

martix wrote:

@misko_2083  Do you have maybe an idea why I can start pmrp via terminal and load the stations but: Putting pmrp in ~/bin makes it available via gmrun (by running "pmrp") but I cannot load the stations that way?

I also made a pmrp.desktop file in /usr/share/applications with

[Desktop Entry]
Encoding=UTF-8
Name=Poor Man's Radio Player
Exec=pmrp
Terminal=false
Type=Application
Icon=radio
Categories=Player;Audio

but it does not show up in the menu structure.

If you are using BL and the Openbox menu then it won't - it is a static menu. Desktop files will only work for dynamic menus.

To add it to the menu you need a command to open the executable in a terminal, or use a wrapper script (which will also appear in dmenu, and run with gmenu)

wrapper script: ~/bin/radio

#!/bin/bash
#
# radio - wrapper for pmrp radio-player

x-terminal-emulator -x pmrp
exit

Menu item for menu.xml:

<item label="pmrp">
	<action name="Execute">
		<execute>
			x-terminal-emulator -x pmrp
		</execute>
	</action>
</item>
man mpg123

or

mpg123 --longhelp

Be Excellent to Each Other...

FORUM RULES and posting guidelines «» Help page for forum post formatting
Artwork on DeviantArt  «» BunsenLabs on DeviantArt

Offline

#54 2017-08-05 16:03:12

martix
Kim Jong-un Stunt Double
Registered: 2016-02-19
Posts: 1,262

Re: The great yad hacking thread

^Thank you @damo. Actually it's been cross-posting - that issue with the menu entry is fixed now. Mostly I'm using dynamic menus (like in this case). It did work with jgmenu before and now it also works with the menu by bl-obmenu-generator. As the posts (and Edit) show I had to add one more keyword to "Categories" that was recognized by bl-obmenu-generator.

Starting pmrp via menu entry (or via gmrun) works fine (as pmrp is in ~/bin), however in these cases the "load stations" feature does not work (although "stations" is also in ~/bin). I tried to start it via "x-terminal-emulator -x pmrp" and it does start, but "load stations" still does not work.

Edit: Or to describe it an other way: When I start pmrp from terminal simply via pmrp being in ~/bin -> everything is fine, "load stations" works. If I'm in a different directory, e.g. in ~, it does start, but does not find "stations" ->

environment: line 3: stations: No such file or directory

Last edited by martix (2017-08-05 16:08:54)

Offline

#55 2017-08-05 16:08:18

damo
....moderator....
Registered: 2015-08-20
Posts: 4,169

Re: The great yad hacking thread

I just copied the pmrp file contents from https://github.com/hakerdefo/pmrp/blob/master/pmrp

The stations are included in the script.


Be Excellent to Each Other...

FORUM RULES and posting guidelines «» Help page for forum post formatting
Artwork on DeviantArt  «» BunsenLabs on DeviantArt

Offline

#56 2017-08-05 16:17:28

martix
Kim Jong-un Stunt Double
Registered: 2016-02-19
Posts: 1,262

Re: The great yad hacking thread

@damo Thank you. It turns out in the end that starting pmrp by putting it in ~/bin and using the "pmrp" command requires "stations" being in the user's home folder, i.e. in ~ (instead of ~/bin).

Now it's truly brilliant: I have a nice menu entry, nice icon and I can even load the stations now!  cool

It's sooo cool, I think it'd even deserve it's own thread in Tips&Tricks as it's a bit hidden here.

Offline

#57 2017-08-05 16:44:19

damo
....moderator....
Registered: 2015-08-20
Posts: 4,169

Re: The great yad hacking thread

martix wrote:

...
It's sooo cool, I think it'd even deserve it's own thread in Tips&Tricks as it's a bit hidden here.

Go right ahead wink


Be Excellent to Each Other...

FORUM RULES and posting guidelines «» Help page for forum post formatting
Artwork on DeviantArt  «» BunsenLabs on DeviantArt

Offline

#58 2017-08-05 16:46:34

Sector11
Tpyo Knig
From: 77345 ¡#
Registered: 2015-08-20
Posts: 5,118

Re: The great yad hacking thread

Hmmmmm I have it in ~/bin
start like this:

terminator --geometry=500x400+90+90 -b -x pmrp

And it works fine.
2017-08-05_134449_Scrot11.th.jpg


BunsenLabs Forum Rules ---== I'm a Conky 1.9'er ==---
System:    Host: s12 Kernel: 3.16.0-4-amd64 x86_64 (64 bit gcc: 4.8.4)
Desktop: Openbox 3.5.2 dm: (startx) Distro: Debian GNU/Linux 8

Offline

#59 2017-08-05 17:25:14

martix
Kim Jong-un Stunt Double
Registered: 2016-02-19
Posts: 1,262

Re: The great yad hacking thread

@S11 There is also a GUI version with a separate "stations" file. If someone uses it via executable in ~/bin (e.g. via gmrun or menu entry), the "stations" file should be in the home folder (or via terminal in the folder where it is started from).

damo wrote:
martix wrote:

...
It's sooo cool, I think it'd even deserve it's own thread in Tips&Tricks as it's a bit hidden here.

Go right ahead wink

Oh, I'm not sure whether maybe Misko_2083 is intending to make a thread like that?

Meanwhile I found here an other brilliant tool: damo's youtube-dl. Really great, will test it now.    cool

Offline

#60 2017-08-05 19:57:59

Sector11
Tpyo Knig
From: 77345 ¡#
Registered: 2015-08-20
Posts: 5,118

Re: The great yad hacking thread

@ martix

OH, OK, I missed that part.  smile  But the terminal part is good enough for me.  big_smile


BunsenLabs Forum Rules ---== I'm a Conky 1.9'er ==---
System:    Host: s12 Kernel: 3.16.0-4-amd64 x86_64 (64 bit gcc: 4.8.4)
Desktop: Openbox 3.5.2 dm: (startx) Distro: Debian GNU/Linux 8

Offline

#61 2017-08-06 07:29:30

martix
Kim Jong-un Stunt Double
Registered: 2016-02-19
Posts: 1,262

Re: The great yad hacking thread

martix wrote:

Meanwhile I found here an other brilliant tool: damo's youtube-dl. Really great, will test it now.    cool


Well, some feedback:
- Starting, closing, setting directory, etc. do work fine
- Downloading only audio works (creates an mpeg4-audio file)
- Downloading a video works as far as it creates an mpeg4-video file but there is no sound
- It creates a file named after the v= part of the url instead of the youtube-name of the video

Btw if I use the command line tool youtube-dl without any special settings, it works nicely and creates an .mkv file named after the youtube name of the video.

Offline

#62 2017-08-06 10:44:19

damo
....moderator....
Registered: 2015-08-20
Posts: 4,169

Re: The great yad hacking thread

Looks like some glitches have developed, and there are gtk3 warnings (due to gvfs?). I'll have a look if I find the time sad


Be Excellent to Each Other...

FORUM RULES and posting guidelines «» Help page for forum post formatting
Artwork on DeviantArt  «» BunsenLabs on DeviantArt

Offline

#63 2017-08-07 01:15:29

misko_2083
Member
Registered: 2016-05-24
Posts: 76

Re: The great yad hacking thread

martix wrote:

@misko_2083  Do you have maybe an idea why I can start pmrp via terminal and load the stations but: Putting pmrp in ~/bin makes it available via gmrun (by running "pmrp") but I cannot load the stations that way?

This line in the script defines the location of stations

export pmrp_stations="stations"

export pmrp_stations="~/bin/stations"
or
export pmrp_stations="/home/your_username/bin/stations"

martix wrote:

Oh, I'm not sure whether maybe Misko_2083 is intending to make a thread like that?

You can make a thread for the pmrp, since it's a command line tool it doesn't belong in this thread.
The PMRP UI tool I'm working on doesn't have all the stations like hakerdefo's. Next, CLI uses mpg123 to play the stations. I've tried using mpg123 but it's built-in remote control has some memory leaks and isn't responsive when the script ends. Sometimes it would take 10 seconds to stop playing, sometimes it would continue playing until the process was killed manualy. big_smile So I swithced to mpv. https://mpv.io/manual/master/#synopsis

As for youtube-dl I made a fork of damo's script and added some bits. https://github.com/Misko-2083/yt-get

Last edited by misko_2083 (2017-08-07 01:45:29)

Offline

#64 2017-08-23 15:41:45

martix
Kim Jong-un Stunt Double
Registered: 2016-02-19
Posts: 1,262

Re: The great yad hacking thread

@misko_2083 I tried to add a radio channel:

## Urban
Urban: "Techno" "Techno" "listen.hardradio.de/stream" 

but somehow this stream does not work on PMRP. Do you have maybe an idea why not?

Btw yt-get is brilliant! Very useful if there is an interesting video (or music) on yt... Oh, and one more thing regarding PMRP: Some kind of simple indicator if it is about to finish a connection to a channel might be a good feature. It takes sometimes several seconds and often I'm not sure if it just takes that long or I did not clicked the channel properly (or it's not available at all...).


Edit: Meanwhile I figured out: http://listen.hardradio.de/stream  works and it has to be with "http://" in the stations file.

Last edited by martix (2017-09-25 11:44:19)

Offline

#65 2017-12-28 00:07:14

yadbash
Member
From: AZ-CA
Registered: 2017-12-27
Posts: 6
Website

Re: The great yad hacking thread

Is there a way to change background color of a yad dialog or make it transparent without changing global gtk window styles ?

I would like for just the button image to show and not the background behind it to create a 10 button horizontal panel and use it as a panel launcher.

If this is possible (change dialog background color or make transparent), I'll create a yad form entry program to set the button parameters. image or color, application to launch or website or place to open.

Offline

#66 2017-12-28 15:47:39

misko_2083
Member
Registered: 2016-05-24
Posts: 76

Re: The great yad hacking thread

yadbash wrote:

Is there a way to change background color of a yad dialog or make it transparent without changing global gtk window styles ?

I would like for just the button image to show and not the background behind it to create a 10 button horizontal panel and use it as a panel launcher.

If this is possible (change dialog background color or make transparent), I'll create a yad form entry program to set the button parameters. image or color, application to launch or website or place to open.

Gtk2 create a gtkrc theme file, and use --gtkrc=/path/to/gtkrc
I've seen it somewhere on puppy forum (I forgot the [↓¢ł→}] password for that forum and there is no way to get it back) there is a script that changes the yad theme on command line.

Gtk3 Like with any gtk3 app, you can change the theme of an application if you set the env GTK_THEME

GTK_THEME=arc-dark yad --title "Arc-dark" --width 100

Transparency is a little tricky. You can maybe use devilspie but that will set the transparency of the whole window with all the widgets.

You can do much more with python, gobject introspection and cairo for semi transparency.

#!/usr/bin/env python

import cairo
from gi import require_version
require_version('Gtk', '3.0')
require_version('Gdk', '3.0')
from gi.repository import Gtk, Gdk

class MyWin (Gtk.Window):
    def __init__(self):
        super(MyWin, self).__init__()
        self.set_position(Gtk.WindowPosition.CENTER)
        self.connect("delete-event", Gtk.main_quit)
        self.set_border_width(30)
        self.screen = self.get_screen()
        self.visual = self.screen.get_rgba_visual()
        if self.visual != None and self.screen.is_composited():
            self.set_visual(self.visual)

        hbox = Gtk.Box(spacing=6)


        button = Gtk.Button.new_with_label("Click Me YadBash")
        button.connect("clicked", self.on_click_me_clicked)
        hbox.pack_start(button, True, True, 0)

        button = Gtk.Button.new_with_mnemonic("_Open")
        button.connect("clicked", self.on_open_clicked)
        hbox.pack_start(button, True, True, 0)

        button = Gtk.Button.new_with_mnemonic("_Close")
        button.connect("clicked", self.on_close_clicked)
        hbox.pack_start(button, True, True, 0)

        self.add(hbox)

        self.set_app_paintable(True)
        self.connect("draw", self.area_draw)
        self.show_all()

    def on_click_me_clicked(self, button):
        button.set_label("You missed YadBash!")
        print("\"Click me\" button was clicked")

    def on_open_clicked(self, button):
        print("\"Open\" button was clicked")

    def on_close_clicked(self, button):
        print("Closing application")
        Gtk.main_quit()

    def area_draw(self, widget, cr):
        cr.set_source_rgba(.2, .2, .2, 0.7)
        cr.set_operator(cairo.OPERATOR_SOURCE)
        cr.paint()
        cr.set_operator(cairo.OPERATOR_OVER)

MyWin()
Gtk.main()

Offline

#67 2017-12-28 17:40:53

yadbash
Member
From: AZ-CA
Registered: 2017-12-27
Posts: 6
Website

Re: The great yad hacking thread

Hi Misko, I have read your many posts in this thread and programs you developed with yad over the last year. Thank you for helping me. It gives me a starting point in the right direction. I'll post back after some testing using your suggestions. Thanks again & Happy New Year. Bobby

Offline

#68 2017-12-29 19:09:02

misko_2083
Member
Registered: 2016-05-24
Posts: 76

Re: The great yad hacking thread

Happy New Year Bobby and other members of the forum.

Offline

#69 2018-04-24 15:16:46

misko_2083
Member
Registered: 2016-05-24
Posts: 76

Re: The great yad hacking thread

I never thought about about this until Stemsee asked this question.

How to save the screen position and dimensions when the yad dialog is moved and/or resized,  then closed so that it reopens in the same place and with the same dimensions?

Something missing with yad is an option to save the position and dialog dimensions when the dialog is closed.
This is one way to go around this. The script saves the position and width and height of a yad dialog and open it in the same position.

xev is used to monitor the window size and position. On destroy event position and dimensions are saved in the $DimFile.

Realaunching the script opens yad dialog with the saved position and width and height.

requires xdotool to get the WindowID

On first run the file to store the absolute position and dimensions will be created.

Don't forget to change the paths here.
DimFile="/home/misko/Desktop/yadXYWH"

#!/bin/bash

# Temp file to store absolute position and dimensions
DimFile="/home/misko/Desktop/yadXYWH"
WorkspFile="/home/misko/Desktop/yadworkspace"

YadClass="Misk0"

[[ ! -f "$DimFile" ]] && >"${DimFile}"

grep -q '[^[:space:]]' < "$DimFile" &&  readarray -t START <"$DimFile"

# run yad
yad --class="$YadClass" --text="$(cat $DimFile)" &
yid="$!"

# xdotool has a buggy behaviour when searching for pid
# on certain distros set the dummy name or class
# in this format:
# xdotool --any --pid $yid --class="$Class"
# until there is a window name do -> sleep
until xdotool getwindowname "$(xdotool search --any --pid $yid --class "$YadClass" 2>/dev/null | tail -1 2>/dev/null)" &>/dev/null; do
        # sleep until the window opens
        sleep .1
done

#Decimal
WindowID="$(xdotool search --any --pid $yid --class "$YadClass" 2>/dev/null | tail -1)"

workspace="$(cat "${WorkspFile}" 2>/dev/null)"

if [[ ${workspace} != "" ]]; then
   # change desktop
   xdotool set_desktop "${workspace: -1}"
   
   # change desktop for window
   xdotool set_desktop_for_window $WindowID "${workspace: -1}"
fi

if [[ ${START[@]} != "" ]]; then
  xdotool windowsize --sync $WindowID ${START[2]} ${START[3]}
  xdotool windowmove --sync $WindowID ${START[0]} ${START[1]}
fi

#Hexadecimal
WindowIDHex=$(printf "0x%08x" ${WindowID})

#Base seven
WindowBSeven=$(printf "0x%07x" ${WindowID})

#Get starting position and size: x, y, width, height
   XWININFO=$(xwininfo -id $WindowIDHex)
   ARRAY=(${XWININFO#* X: })
   AX=${ARRAY[0]}
   AY=${ARRAY[4]}
   RX=${ARRAY[8]}
   RY=${ARRAY[12]}
   W=${ARRAY[14]}
   H=${ARRAY[16]}
   X=$((AX))
   Y=$((AY)) 

# This monitors the window absolute-top-left x, y, width and height for changes
# If the window is moved - this will get new pos and size
# On destroy event, saves X,Y, W, and H
xev -event structure -id ${WindowIDHex} 2>/dev/null |
       while IFS=$',' read -a A;do
            if [[ "${A[0]#"${A%%[![:space:]]*}"}" =~ "event ${WindowBSeven}" && "${A[1]}${A[2]:1:1}${A[3]: -1}" =~ "window ${WindowBSeven}()" ]]; then
                  X="${A[2]//" ("/}"
                  Y="${A[3]%")"}"
                  W="${A[4]//" width "/}"
                  H="${A[5]//" height "/}"
            # On destroy event
            elif [[ "${A[0]}" =~ "DestroyNotify event" ]]; then
                  >"${DimFile}"
                  X=$((X-RX))
                  Y=$((Y-RY)) 
                  # Exports dimensions
                  echo "$X" >> "${DimFile}"
                  echo "$Y" >> "${DimFile}"
                  echo "$W" >> "${DimFile}"
                  echo "$H" >> "${DimFile}"
                  # save current workspace
                  workspace="$(xprop -root -notype _NET_CURRENT_DESKTOP 2>/dev/null)"
                  echo "${workspace:-1}" > "${WorkspFile}"
                  exit
            fi
             A=()
        done &

wait $yid
EXIT_STATUS=$?

# xev dies hard
XevPID="$(ps -eo pid,cmd | grep "xev -event structure -id $WindowIDHex" | grep -v "grep" | awk '{ print $1 }')"
kill $XevPID 2> /dev/null

echo "Our exit status: $EXIT_STATUS"
exit 0

It can probably be be modified for use with a few other applications. Of course, with the help of xdotool to move the window in place and resize that application's window.
xdotool windowsize $WindowID ${W} ${H}
xdotool windowmove $WindowID ${X} ${Y}

Last edited by misko_2083 (2018-04-25 00:43:01)

Offline

#70 2018-04-24 15:52:34

PackRat
Member
Registered: 2015-10-02
Posts: 730

Re: The great yad hacking thread

misko_2083 wrote:

I never thought about about this until Stemsee asked this question.

How to save the screen position and dimensions when the yad dialog is moved and/or resized,  then closed so that it reopens in the same place and with the same dimensions?

Something missing with yad is an option to save the position and dialog dimensions when the dialog is closed.
This is one way to go around this. The script saves the position and width and height of a yad dialog and open it in the same position.

The other way to do this is to utilize the "--class" and "--name" options in your yad scripts and let the window manager's per app settings handle the placement.

In fluxbox I have this key binding:

OnToolbar Mouse2 :Exec yad --name=FluxCal --class=FluxCal --title=Calendar --calendar --text ""

in the apps file (fluxbox per app settings)

[app] (name=FluxCal) (class=FluxCal)
  [Dimensions]	{21% 43%}
  [Position]	(UPPERLEFT)	{74% 46%}
  [Shaded]	{no}
  [Deco]	{0x66f}
  [Sticky]	{no}
  [Minimized]	{no}
  [Maximized]	{no}
  [Fullscreen]	{no}
  [Layer]	{8}
  [Alpha]	{255}
[end]

so mouse buttin 2 on the toolbar always places the calendar in the same spot and same dimensions.

Can set that up in the openbox rc.xml file as well, or any window manager that uses the name and class for per app settings.


It is difficult to get a man to understand something when his salary depends upon his not understanding it.
                                                                                                                                       Upton Sinclair

Offline

#71 2018-04-24 19:07:34

misko_2083
Member
Registered: 2016-05-24
Posts: 76

Re: The great yad hacking thread

PackRat wrote:
misko_2083 wrote:

I never thought about about this until Stemsee asked this question.

How to save the screen position and dimensions when the yad dialog is moved and/or resized,  then closed so that it reopens in the same place and with the same dimensions?

Something missing with yad is an option to save the position and dialog dimensions when the dialog is closed.
This is one way to go around this. The script saves the position and width and height of a yad dialog and open it in the same position.

The other way to do this is to utilize the "--class" and "--name" options in your yad scripts and let the window manager's per app settings handle the placement.

....
so mouse buttin 2 on the toolbar always places the calendar in the same spot and same dimensions.

Can set that up in the openbox rc.xml file as well, or any window manager that uses the name and class for per app settings.

Hi PackRat,
That is interesting, thanks for sharing.

You mention that with mousebutton 2, the window will be positioned in the fixed geometry and position.

Can Fluxbox save a window's position and size on exit?
And can a new window be in the the exact saved position with the same size, like when using the script above?

Offline

#72 2018-04-24 20:15:44

PackRat
Member
Registered: 2015-10-02
Posts: 730

Re: The great yad hacking thread

^ That's exactly what fluxbox does. For that example the calendar opens in the same location with the same geometry.

Can Fluxbox save a window's position and size on exit?
And can a new window be in the the exact saved position with the same size, like when using the script above?

Fluxbox has a save on close option that can be set for per app settings. So if a user opens a window with pre-defined settings, then moves and resizes it, the new position and size will be saved to the per app settings in the ~/.fluxbox/apps file. New windows will open at the new position with the new geometry. I'm not sure if any other window manager has this feature natively..

Last edited by PackRat (2018-04-24 21:19:27)


It is difficult to get a man to understand something when his salary depends upon his not understanding it.
                                                                                                                                       Upton Sinclair

Offline

#73 2018-04-25 00:47:31

misko_2083
Member
Registered: 2016-05-24
Posts: 76

Re: The great yad hacking thread

PackRat wrote:

Fluxbox has a save on close option that can be set for per app settings. So if a user opens a window with pre-defined settings, then moves and resizes it, the new position and size will be saved to the per app settings in the ~/.fluxbox/apps file. New windows will open at the new position with the new geometry. I'm not sure if any other window manager has this feature natively..

That's a neat feature. Didn't see that in other wms. Xfwm uses Smart Placing and cannot be deactivated.. Other's probably have their versions.

There was a bug in my script positioning windows +24 pixels under absolute-left Y and -1 pixel next to absolute left X on each cycle. Fixed now ( edited my post ) + added a feature that places the window in the workspace where it was closed. smile

Trying something similar with Thunar now. It's probably much easier with Fluxbox. smile

#!/bin/bash

# Temp file to store absolute position and dimensions
DimFile="/home/misko/Desktop/ThunarXYWH"
WorkspFile="/home/misko/Desktop/Thunarworkspace"

[[ ! -f "$DimFile" ]] && >"${DimFile}"

grep -q '[^[:space:]]' < "$DimFile" &&  readarray -t START <"$DimFile"

app=thunar
$app

# Check for running instances of $app on current desktop/workspace.
until xdotool getwindowname "$(xdotool search --desktop $(xdotool get_desktop) --class $app 2>/dev/null | tail -1 2>/dev/null)" &>/dev/null; do
        # sleep until the window opens
        sleep .1
done

#Decimal
WindowID="$(xdotool search --desktop $(xdotool get_desktop) --class $app 2>/dev/null | tail -1)"

workspace="$(cat "${WorkspFile}" 2>/dev/null)"

if [[ ${workspace} != "" ]]; then
   # change desktop
   xdotool set_desktop "${workspace: -1}"
   
   # change desktop for window
   xdotool set_desktop_for_window $WindowID "${workspace: -1}"
fi

if [[ ${START[@]} != "" ]]; then
  xdotool windowsize --sync $WindowID ${START[2]} ${START[3]}
  xdotool windowmove --sync $WindowID ${START[0]} ${START[1]}
fi

#Hexadecimal
WindowIDHex=$(printf "0x%08x" ${WindowID})

#Base seven
WindowBSeven=$(printf "0x%07x" ${WindowID})

#Get starting position and size: x, y, width, height
   XWININFO=$(xwininfo -id $WindowIDHex)
   ARRAY=(${XWININFO#* X: })
   AX=${ARRAY[0]}
   AY=${ARRAY[4]}
   RX=${ARRAY[8]}
   RY=${ARRAY[12]}
   W=${ARRAY[14]}
   H=${ARRAY[16]}
   X=$((AX))
   Y=$((AY)) 

# This monitors the window absolute-top-left x, y, width and height for changes
# If the window is moved - this will get new pos and size
# On destroy event, saves X,Y, W, and H
xev -event structure -id ${WindowIDHex} 2>/dev/null |
       while IFS=$',' read -a A;do
            if [[ "${A[0]#"${A%%[![:space:]]*}"}" =~ "event ${WindowBSeven}" && "${A[1]}${A[2]:1:1}${A[3]: -1}" =~ "window ${WindowBSeven}()" ]]; then
                  X="${A[2]//" ("/}"
                  Y="${A[3]%")"}"
                  W="${A[4]//" width "/}"
                  H="${A[5]//" height "/}"
            # On destroy event
            elif [[ "${A[0]}" =~ "DestroyNotify event" ]]; then
                  >"${DimFile}"
                  X=$((X-RX))
                  Y=$((Y-RY)) 
                  # Exports dimensions
                  echo "$X" >> "${DimFile}"
                  echo "$Y" >> "${DimFile}"
                  echo "$W" >> "${DimFile}"
                  echo "$H" >> "${DimFile}"
                  # save current workspace
                  workspace="$(xprop -root -notype _NET_CURRENT_DESKTOP 2>/dev/null)"
                  echo "${workspace:-1}" > "${WorkspFile}"
                  # xev dies hard
                  XevPID="$(ps -eo pid,cmd | grep "xev -event structure -id $WindowIDHex" | grep -v "grep" | awk '{ print $1 }')"
                  kill $XevPID 2> /dev/null
            fi
             A=()
        done

exit 0

Offline

#74 2018-05-12 21:03:56

misko_2083
Member
Registered: 2016-05-24
Posts: 76

Re: The great yad hacking thread

I answered a question on how to remove highlight from a yad form date field.
this is the relevant line:

printf "%s\n" "12/05/18" "4:40" | yad --form --field="Date:DT"  --field="Date" --cycle-read

Apparently, when selecting a new date from a date field, that field gets highlited.
When selecting a date, a new window pops out displaying a calendar.
When a new date is selected and the calendar window closed the date is highlited.

To make this work the form dialog needed to be monitored somehow
and when it's active to send a keyboard key combo ctrl+right with xdotool.

Since most modern wm's support _NET_ACTIVE_WINDOW, that's what I used.
In that process i managed to get arround that strage array bug in the while loop.

xprop -root -spy _NET_ACTIVE_WINDOW |  # <- this is the watcher process
     while IFS=$'#' read -a WIN; do
         WIN="${WIN[1]%%","*}"
         WIN="$(printf "%s\n" ${WIN})"  # bypass weird array bug

         if [[ "${WIN}" == "${WindowIDbSeven}" ]]; then
             xdotool key --clearmodifiers "$WindowIDbSeven" ctrl+Right # send ctrl+Right
         fi
          WIN=()
     done & WATCH_PID=$!

Adding a newline at the end of the string seems to "do the job". big_smile

Full script on gist:
https://gist.github.com/Misko-2083/3822 … be10560963

Cheers everyone.

Offline

#75 2018-05-16 23:40:07

yadbash
Member
From: AZ-CA
Registered: 2017-12-27
Posts: 6
Website

Re: The great yad hacking thread

Hi Misko and others ! I'm going to spend the next 30 days working on Yad once again and have a button layout question.

Is there a way to have a Grid of Form Buttons that fills a whole yad window ? The whole screen size ?

I can do this with multiple yad windows and position them one below the other but, even when I set all yad windows to with "behind display properties", programs will get between the multiple windows.

This is what I am trying to accomplish using only One Yad Window:

https://www.youtube.com/watch?v=a-Iy7YeeW8A

Thanks for helping, Bobby

Offline

Board footer

Powered by FluxBB