Workspaces command line (was: Key combo remapping?)

Is there a general mechanism for remapping key combinations in Haiku?

Or a specific one for remapping the Workspace switching key combos?

Specifically, it doesn’t make sense to me that the arrow combo is CTRL-ALT-arrow when the direct switch combo is ALT-F#; I’d like to remap that to be CTRL-arrow and CTRL-F# instead.

(ALT-arrow is already normal in the web browsers to switch back to the previous page and forward to a previously-followed link.)

I’m not sure about remapping, but I just tested creating the ctrl-arrow and ctrl-f# shortcuts inside of the Shortcuts preference application and they worked fine. The Workspaces application has some hidden command line options that can be used in the shortcut. You can use /system/apps/Workspaces 3 to change to workspace 3, for instance; and you can use the +/- arguments to change to the next/previous workspace, like /system/apps/Workspaces + or /system/apps/Workspaces -

1 Like

I had no idea; that’s really interesting.

If I can come up with some way of identifying the current workspace from a command line, I can make shortcuts to do this.

Thanks!

Hah; and now that I know to search for that it turns out this has kinda already been discussed here: Get current workspace #? - #4 by zuMi

You shouldn’t need to identify the current workspace in order to do the things in your original message. If you want to jump to a different workspace with ctrl-f# then you set a shortcut with /system/apps/Workspaces #, and if you want to increment/decrement the workspace with ctrl-arrow then you can set the command to be /system/apps/Workspaces + or /system/apps/Workspaces -

Edit: You’re probably talking about arrow up/down. I forget about that because I use a single row of workspaces

1 Like

I have my workspaces in a 4x3 grid, and I’m used to using the up and down arrows as well as left and right to navigate.

CTRL-down should do something like current workspace + 4, mod 12.

That’s great. Even without UP and DOWN you got me like 90% of how I wanted it to work. Thank you muchly.

Well, I can’t find any existing way to get the current workspace from the command line so I guess it’s time to dust off the C++.

I haven’t written in C++ pretty much at all since I moved off BeOS. :slight_smile:

I’ve got a console app put together that can give me that info now, so once I’m sure it’s legit I’ll go look up the source to the workspaces app and see about putting together a patch or PR to add that info to its output.

We usually avoid overloading gui apps with cli stuff, instead adding this to proper cli commands. maybe screenmode is a better candidate? It should probably already deal with this stuff

I was thinking it should be added to the output that’s described here:

as a way of getting information about the current workspaces layout from the command line.

If I understand correctly, that’s sending a message requesting information to the Workspaces app?

No, that is reading a config file in the BMessage archive format, converting it to a text based format and then using unix text tools to work on that

Well, I misunderstood what “message” as a command line tool would be doing. :slight_smile:

I’ve been away from BeOS for a loooong time.

If I wanted to publish something that other folks with the same need could use from the command line then it’d probably be best to approach it as a standalone command line tool for interacting with the workspaces.

Thanks for the explanation.

Well, screenmode probably already needs this functionality since you can set per-workspace resolution. I don’t know how much is exposed right now, but barring making a new cli tool (which is probably ok too) It looks like the right place to me :slight_smile:

1 Like

screenmode doesn’t seem to have any workspaces-related arguments at the moment:

~/scripts> screenmode --help
Usage: screenmode [options] <mode>
Sets the specified screen mode. When no screen mode has been chosen,
the current one is printed. <mode> takes the form: <width> <height>
<depth> <refresh-rate>, or <width>x<height>, etc.
      --fall-back       changes to the standard fallback mode, and displays a
                        notification requester.
  -s  --short           when no mode is given the current screen mode or

                        the screen brightness is printed in short form.
  -l  --list            display a list of the available modes.
  -q  --dont-confirm    do not confirm the mode after setting it.
  -b  --brightness f    set brightness (range 0 to 1).
  -b  --brightness +/-f change brightness by given amount.
  -B  --get-brightness  print the current brightness to stdout.
                        instead of the screen mode
  -m  --modeline        accept and print X-style modeline modes:
                          <pclk> <h-display> <h-sync-start> <h-sync-end> <h-total>
                          <v-disp> <v-sync-start> <v-sync-end> <v-total> [flags] [depth]
                        (supported flags are: +/-HSync, +/-VSync, Interlace)

I defer to your experience, but to me it seems better not to try to merge workspaces-related stuff into that.

Man, my C++ is rusty. :slight_smile:

But I’ve got a command-line C++ app put together than can output the current workspace, number of rows and total number of workspaces, switch to a workspace by number, switch left or right in the linear sequence of workspaces and switch up or down a row in the grid of workspaces.

And using the Shortcuts preferences, I can do all that with CTRL-[whatever] so I have it exactly as I wanted it. Yay!

I need to build a VM to host a Forgejo, but once I’ve done that I’ll bundle this up and PR it to haikuports.

(If you want it before then, PM me and I’ll email you the project directory.)

I used Genio to throw it together, which worked pretty well.

1 Like

Honestly that seems more like something that should be in Haiku proper if you are interestef in uostreaming it :slight_smile:

I would be honored. :slight_smile:

I need to look at coding style y’all use and try to learn how submissions to the main repo work.

It’s only a 206-line .cpp file, so i shouldn’t take much to make it fit in.

It is called ‘workspacesctl’ at the moment, because I had to name it something; I am not committed to that name.

Well, since I referred to the source for screenmode a bit while putting workspacesctl together meeting the coding style guideline doesn’t look too difficult. :slight_smile:

I did use a global variable, so I should probably try to figure out a way to get that from main() into the BeApp object without being global.

OK, I tidied things up a bit and got rid of the global variable by re-learning how to do instance variables on a class. :slight_smile:

I also added some functionality, so it can now go:

  • plus and minus by workspace number
  • left and right on a row
  • up and down in a column
  • directly to a workspace by number

Plus/minus, left/right and up/down also cycle correctly within their sets (i.e. going right from the rightmost column will put you in the leftmost column on the same row, etc.).

I have no idea how to integrate a new app into the Haiku build system, but I think I can figure out how to do a PR for adding the source file to the correct part of the repo. :slight_smile:

Given that Workspaces already handles switching to a workspace by calling it with an argument and behaves as a CLI app when doing so, I don’t find it unreasonable to add left, right, up and down (or something like that) to the accepted ones on top of the number and + and -.