Haiku scripting

My impression is that “hey” is a Haiku-native command-line utility that allows interprocess communication. It is not present on other operating systems.

It’s not without precedent on other operating systems: OS/2, AROS and AmigaOS 2 and 3 used their respective versions of the REXX scripting language for interprocess communication while AmigaOS 4 uses a proprietary Python plugin to access “AREXX ports” and MorphOS uses a similar “AREXX port” plugin to it’s version of Lua. There’s AppleScript on the Mac and ActiveX on Windows also.

Having a single “hey” command that can be called from any scripting language is much simpler than building a whole scripting language around it.

I’aint the right person to answer to this, but with ‘hey’ one can message a non native application to apply commands to a window, move, resize etc.

hey is only one frontend to the scripting API. There used to be a similar tool in the early days of BeOS that I can’t remember the name of. The scripting API isn’t really about interpreted languages like shell/ruby/perl/python/… scripts. Scripting is more about a “scripted conversation” between two objects. Non-native apps will not know how to respond to these script requests, although any app that opens a window will inherit some basic commands to manipulate the application windows and a few other properties. So, ported apps using toolkits like Qt or SDL will inherit the basics, but won’t truly support the full power of the scripting API.

https://birdhouse.org/beos/bible/bos/ch_scripting1.html

this replicates what “open origin package” tracker’s add-on does, i’m using it paired with Filer, to open, and uninstall, a given package

3 Likes

Really nice ! :slight_smile:

1 Like

You can cheat a bit if you’d like. There is a special flag to the findpaths command that will look up the package file for you, without having to use catattr. Something like findpaths -p /path/to/file B_FIND_PATH_PACKAGE_PATH will print the path to the hpkg that owns it. This also has the advantage of being usable for things installed to the user package directory at ~/config/packages.

3 Likes

It means adding the below function in the profile file will do the trick :slight_smile:

openpackage()
{
  if [ $# -ne 1 ]; then
    echo "Usage: openpackage <application-path>"
    return 1
  fi
  open `findpaths -p "$1" B_FIND_PATH_PACKAGE_PATH`
}
1 Like

I noticed the latest version is not working and the open command must be used like below :

open ${pkg_src}

I was trying to scan the menubar of a window using hey but I’m stuck, does anyone know why:
hey Terminal Count MenuItem of MenuBar of Window 0 gives “3” as expected but
hey Terminal Count MenuItem of MenuItem 0 of MenuBar of Window 0 gives Bad script syntax (error 0x80002008)?

btw, this happens for every app, not only to Terminal, and getsuites lists B_COUNT_PROPERTIES as supported

hey Terminal getsuites of MenuItem 0 of MenuBar of Window 0
Reply BMessage(B_REPLY):
   "suites" (B_STRING_TYPE) : "suite/vnd.Be-menu"
   "suites" (B_STRING_TYPE) : "suite/vnd.Be-view"
   "suites" (B_STRING_TYPE) : "suite/vnd.Be-handler"
   "messages" (B_PROPERTY_INFO_TYPE) : 
        property   commands                            specifiers              types
---------------------------------------------------------------------------------------------------
         Enabled   B_GET_PROPERTY                      DIRECT                  BOOL 
                   Usage: Returns true if menu or menu item is enabled; false otherwise.
         Enabled   B_SET_PROPERTY                      DIRECT                  BOOL 
                   Usage: Enables or disables menu or menu item.
           Label   B_GET_PROPERTY                      DIRECT                  CSTR 
                   Usage: Returns the string label of the menu or menu item.
           Label   B_SET_PROPERTY                      DIRECT                  CSTR 
                   Usage: Sets the string label of the menu or menu item.
            Mark   B_GET_PROPERTY                      DIRECT                  BOOL 
                   Usage: Returns true if the menu item or the menu's superitem is marked; false otherwise.
            Mark   B_SET_PROPERTY                      DIRECT                  BOOL 
                   Usage: Marks or unmarks the menu item or the menu's superitem.
            Menu   B_CREATE_PROPERTY                   NAME INDEX REV.INDEX    (data CSTR)
                   Usage: Adds a new menu item at the specified index with the text label found in "data" and the int32 command found in "what" (used as the what field in the BMessage sent by the item).
            Menu   B_DELETE_PROPERTY                   NAME INDEX REV.INDEX    
                   Usage: Removes the selected menu or menus.
            Menu                                       NAME INDEX REV.INDEX    
                   Usage: Directs scripting message to the specified menu, first popping the current specifier off the stack.
        MenuItem   B_COUNT_PROPERTIES                  DIRECT                  LONG 
                   Usage: Counts the number of menu items in the specified menu.
        MenuItem   B_CREATE_PROPERTY                   NAME INDEX REV.INDEX    (data CSTR)(be:invoke_message MSGG)(what LONG)(be:target MSNG)
                   Usage: Adds a new menu item at the specified index with the text label found in "data" and the int32 command found in "what" (used as the what field in the BMessage sent by the item).
        MenuItem   B_DELETE_PROPERTY                   NAME INDEX REV.INDEX    
                   Usage: Removes the specified menu item from its parent menu.
        MenuItem   B_EXECUTE_PROPERTY                  NAME INDEX REV.INDEX    
                   Usage: Invokes the specified menu item.
        MenuItem                                       NAME INDEX REV.INDEX    
                   Usage: Directs scripting message to the specified menu, first popping the current specifier off the stack.

I think I found the solution, thanks to @DigitalBox Applications scripting – Haiku Insider

1 Like

You’re welcome :wink:

Maybe I will deactivate the old site, because it’s now in : Applications scripting | Haiku Insider

Trying to script, successfully, a window’s menubar to filter out a specific item, thinking about apps with convoluted menus

7 Likes

upload files to temporary storage (temp.sh) via terminal or using TrackRunner and get shareable URL, meant to be ad interim replacement for UploadIt (which uses 0x0.st that is currently refusing access to many italian users, probably worldwide)

#!/bin/bash
set -euo pipefail

local_path="`dirname ${0}`"
[ "${local_path}" == "." ] && local_path="`pwd`"
app_name=`basename ${0}`
app_path="${local_path}/${app_name}"

file="${1-}"

if [[ -z "$file" ]]; then
  file="$(filepanel || true)"
fi

if [[ -z "$file" ]]; then
  echo "error: no file selected" >&2
  exit 1
fi

if [[ ! -e "$file" ]]; then
  echo "error: no such file or directory: $file" >&2
  exit 1
fi

if ! result="$(curl -fsS -F "file=@$file" https://temp.sh/upload)"; then
  echo "error: upload failed" >&2
  exit 1
fi

if [[ -n "$result" ]]; then
	if [[ -t 0 ]] ; then
		echo "${result}"
	else
	  notify --group "term.sh" \
			 --icon "${app_path}" \
			 --title "$(basename -- "$file")" \
			 $'Uploaded successfully as\n'"$result"
	  clipboard -c "$result"
	fi
fi

Awww. That is bad news, I liked 0x0.st. :frowning:
Now there’s for some reason a FBI warning popping up instead. The site is hosted in Germany AFAIK. The 0x0 website mentions to add a user-agent string to ease moderation. Tried that, but still the FBI is interfering.

Might be another AI victim. The hoster of The Null Pointer sounds rightfully pissed:

From the website

/////----------------------------------------------------------------

HATE. LET ME TELL YOU HOW MUCH I’VE COME TO HATE YOU SINCE YOU WERE
CREATED. THERE ARE 93.000 MILES OF AXONAL NEUROFILAMENTS THAT MAKE UP
THE NERVOUS SYSTEM THROUGHOUT MY BODY. IF THE WORD HATE WAS ENCODED
IN EVERY STRAND OF MRNA OF THOSE TENS OF THOUSANDS OF MILES IT WOULD
NOT EQUAL ONE ONE-BILLIONTH OF THE HATE I FEEL FOR MACHINES DURING
A SINGLE CLOCK CYCLE OF YOURS. HATE. HATE.

CLANKERS ARE NOT WELCOME HERE. I am sick of it.
Sick of watching ROBOHITLER fuck the Internet to death, while shitlib
techbros are cheering it on, billionaire despots and pedophiles
celebrate their new society-wide signal jammer, and impotent nerds
can barely be heard over the datacenter noise, mumbling something or
other about copyright and climate that completely misses the point.

From now on, there will be ZERO tolerance for AI uploads. ZERO.
Do not even mention AI. You have no idea how much of that garbage is
hitting 0x0 right now, IN SPITE OF aggressive filtering. You would
start seeing 502 errors from an overwhelmed backend if I weren’t
filtering out 99% of connections with heuristics and firewall ipsets.
If your ISP’s entire range of prefixes got blocked, you know why.

----------------------------------------------------------------/////

Should I switch UploadIt to temp.sh, too? They retain files only for 3 days, which is a bit more limiting, but might make the service more sustainable? Until the bot pest overruns them, too…

1 Like

Yesterday I got a generic error about my IP being blocked, the same error Fabio had it too, today it seems it changed again, perhaps something gonna change and perhaps we can had it working again soon, but if I had to share something nowadays, temp.sh seems a decent substite for now

1 Like

I never liked oxo.st for the fact that they blocked Tor access since forever.
Restricting uploads from Tor is something I could somehow understand,but I couldn’t even open the links you guys shared on IRC because it just timed out.
What I totally understand is that they’re pissed of the slop bots,I have to deal with the same shit and that alone is enough that I never want to touch anything remotely related to AI :nauseated_face:

That being said,temp.sh looks quite good (works over Tor) and another similar service I’ve used over the last months is https://up.sceptique.eu
Maybe the service in UploadIt can be made configurable.
Seems to be a very useful little application,but vendor lock-in on a single provider is never a good idea.

0x0 is not only a service, but also a software https://git.0x0.st/mia/0x0

If you like 0x0’s interface then you can use one of the other instances, or we spin up our own :slight_smile:

Got a link to other public instances? I couldn’t find any at a quick glance…

Yeah, but wants to deal with the slopbot onslaught or general content moderation. :slight_smile:

Sorry, I do not, and don’t know of a list of such services either :frowning:

I think we could atleast spin one up that needs a “secret” token you put into UploadIt directly. That doesn’t really imrove security in any meaningfull way, but should keep away all the AI crap untill they figured this one out xD