elkowar / eww

ElKowars wacky widgets
https://elkowar.github.io/eww
MIT License
9.4k stars 381 forks source link

[FEATURE] Close widgets From Inside the .yuck file #700

Closed HalfdeadBone closed 1 year ago

HalfdeadBone commented 1 year ago

Description of the requested feature

As the title said - simple comand inside .yuck that could CLOSE or CLOSEALL widgets in choosen daemon?

Workaround : Thanks to --config flag we can use sh like this:

CFG=`pwd`
EWW=`which eww`
${EWW} --config "$CFG" close $@

(Same goes for opening) because daemon runs it the chosen config pwd (command for "where am i" in linux) with chosen widgets it is posible to close and open them.

Using this command we execute :onclick "/close.sh widget" for the output of what widget is opened in directory via (deflisten ALLWIDGETS ./allwidgets.sh )

CFG=`pwd`
EWW=`which eww`
echo `${EWW} --config "$CFG" windows | tr -d '*'`

HOWEVER this solution kills ALL widgets - even inactive.

Proposed configuration syntax

You can associate the action like in previous part, by sending eww call from pwd Whole example here https://github.com/HalfdeadBone/CloseYuckExample

OR

By using Built in functions, that has been written in rust + how the daemon works:

I don't know rust to do the commit Edit: I'm gonna try.

Additional context

No response

elkowar commented 1 year ago

Eww provides you with the EWW_CMD magic variable, which can be used to simplify your command in this case. With that, your on-click handler or whatever can look like :onclick "${EWW_CMD} close my-widget or `:onclick "${EWW_CMD} close-all, respectively. I'm not quite sure what exactly you're asking for here, to be honest

HalfdeadBone commented 1 year ago

Oh sorry i am overthinker and i caused a little chaos. I have started to do the explanation of what i am doing and later didn't precise proposition

So the problem that i had, was that sometimes when using bash the location or naming might be off and you need to do it statically or think around it to make it dynamic. Also i have not found any Dynamic solution, to call for names, at least in projects from /r/unixporn. (mostly names of all widgets) My thinking, was that the best option would be $CLOSE_ALL and $CLOSE and W_NAMES (widget names) for 2 reasons:

  1. It's faster cause program can provide the name without calling it thru bash (what makes it faster, than running it in bash)
  2. I had no idea About the $EWW_CMD variable - i missed it in "Magic Variables" and i have spent some time to find a workaround solution.

Sorry for the chaos.