Skip to content
This repository has been archived by the owner on Feb 17, 2023. It is now read-only.

Wanted: sketch to activate bundle when hardware is present #246

Open
nickanderson opened this issue Feb 1, 2013 · 7 comments
Open

Wanted: sketch to activate bundle when hardware is present #246

nickanderson opened this issue Feb 1, 2013 · 7 comments
Assignees
Milestone

Comments

@nickanderson
Copy link
Member

A generic form of the disable/enable wifi when docked/undocked example.

usebundle when present, usebundle when absent
compare user defined string to lspci, lsusb, lshw output?

Thoughts?

@zzamboni
Copy link
Contributor

zzamboni commented Feb 1, 2013

Sounds useful, particularly for desktop management. Could be used to trigger syncing with a handheld when connected, reconfigure CUPS when a printer is connected, etc.

@tzz
Copy link
Contributor

tzz commented Feb 1, 2013

I propose Util::Trigger

  • param1: command to execute (execresult will be checked). Use "$(paths.grep) -q" to find a string in a file. Use $(paths.true) to always succeed.
  • param2: context string for when to check the execresult, e.g. "Monday". This can be a more complex expression if you want to use external knowledge and not an execresult.
  • param3: bundle to run when execresult is OK. Default=empty string. No parameters.
  • param4: bundle to run when execresult is not OK. Default=empty string. No parameters.

@nickanderson
Copy link
Member Author

$(paths.grep) and $(paths.true)? I dont think the paths sketch made it through the last overhaul. Guessing it should be moved to a library.

@nickanderson
Copy link
Member Author

I think we would need another param with a list of strings to look for in the execresult output, or I am not understanding your param1 proposal

@tzz
Copy link
Contributor

tzz commented Feb 1, 2013

The paths bundle is in the stdlib, recently. I think CFEngine::stdlib needs to be updated from core.git.

In param1, grep can do lists of strings, and you can use many other commands if it's a generic shell command (e.g. $(paths.tail) -200 to make sure the command doesn't take too long). I think that's better and more generic than making it specifically a grep pipeline and passing a list of strings. But please, it's your sketch, so if you like it better in a different way, go for it! I was just trying to help with suggestions.

@nickanderson
Copy link
Member Author

oh so you were thinking something like this?

vars:
"commands" slist => { "lspsi", "lsusb" };
"trigger_strings" slist => { "Lenovo Dockstring", "my big usb drive" };

methods:
usebundle => trigger_strings("$(commands) | $(paths.grep) $(trigger_strings)", context, match_active_bundle, nomatch_activate_bundle)

@ghost ghost assigned tzz Feb 15, 2013
@tzz
Copy link
Contributor

tzz commented Feb 15, 2013

Yup, exactly. Assigned to myself in case you don't get to it.

tzz pushed a commit to tzz/design-center that referenced this issue Jun 1, 2014
Made sure page is set to False. Played around with text box ideas.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

No branches or pull requests

3 participants