How to load a package using a custom event?

I initially sent this question via email. Posting here to share the answer.

Good evening,

I was wondering if there’s way to call up or load a package in RV by using a custom event? I’m just using the quickFullscreen package that was on the forums as an example here. The PACKAGE file for quickFullscreen has the following:

- file: quickFullscreen
  load: delayed
  event: 'key-down--alt--`'

What can I do if I want to load this package by doing a sendEvent? Right now I can do something like:


My script will launch rv just fine, do some other things, and then load/activate the quickFullscreen package by sending a keypress event, but I’m sure there’s a more elegant way to do it that I am unaware of.

Thank you!

The answer that was sent to me was:

You’re almost there, in fact, that looks pretty good! We unfortunately don’t expose a way to programmatically interact with preferences, but binding on events is pretty close.

One thing that you can do to improve your code below is to name your event something else, so that you’re not directly binding to the key.

It would look something like:
- file: quickFullscreen
load: delayed
event: ‘foobar`’


This way you can abstract the event to something that looks nicer.

Also, did you know that you can use -sendEvent from the command line? In that case, RV will pre-pend external- prefix to the event, and you can bind it the same way as above but it would be external-foobar.

Hope this helps!

1 Like

I have another question though. If I want to take it a step further and have the package print a custom string that I pass as an event argument. How do I do that?

I know that I can do something like this to declare an event:
rv.commands.bind('default', 'global', 'foobar', self.process_event_data, '')

Then in my function I can use event.contents().

However, I’m unclear on what exactly I should do so that when I do a remoteSendEvent('foobar', '', 'hello world'), the package will be loaded and at the same time process my event data. Any help would be appreciated.

Hi Michael!

You should be able to process your event in a similar way. For rv.commands.bind, it works best if you already have a function to bind to, this is typically the best way to remap hotkeys, since the built-in functions within RV are typically available at runtime.

For remoteSendEvent, you’ll need to have a separate package that will be able to capture this event and define a function within that package that will do something. So for example, if you send an event called foobar, you’ll need to bind to foobar event within RV. For example:

class ExampleMode(rvtypes.MinorMode):

    def __init__(self):

        # Don't bind to menu
        menu = []

                  [("foobar", self.yourFunction, "Event name for event table")],

    def yourFunction(self, event):
        contents = event.contents()
        print "This is my contents", contents

def createMode():
    return ExampleMode()

Hope this helps!