Skip to content

add switch-mode option to the script mode#2196

Merged
DaveDavenport merged 6 commits intodavatorium:nextfrom
tmoron:next
Sep 24, 2025
Merged

add switch-mode option to the script mode#2196
DaveDavenport merged 6 commits intodavatorium:nextfrom
tmoron:next

Conversation

@tmoron
Copy link
Contributor

@tmoron tmoron commented Sep 20, 2025

Added an option to switch modes from a script.
Usage :

echo -e "\0switch-mode\x1fdrun"

this switches to the drun mode

@DaveDavenport
Copy link
Collaborator

What is the use-case for this patch?

@tmoron
Copy link
Contributor Author

tmoron commented Sep 21, 2025

I want to create a kind of submenu system in the launcher, where different prefixes trigger different modes or actions. For example, typing d would switch to drun, typing c would switch to calc, and other prefixes could be used to start Firefox with a search or open a bookmark.

int16_t switch_mode;
} ScriptModePrivateData;

extern unsigned int curr_mode;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not a big fan of this 'bypass' of the mode API.
I need to remember exactly how it works, Maybe we can use MENU_QUICK_SWITCH structure.

I think if you return the mode number from the _result function it should switch to that mode..

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See process_result in rofi.c

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, returning the id of the mode does switch to that mode,that's what I had initially. but this method doesn't clear the input and the next mode starts with the previous mode's input. So if I start drun with "d" in script, drun mode will be started with a d already entered. I avoided adding a clear in the default switch to prevent breaking other behavior.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

free and set *input to NULL?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image That should clear it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh, I didn't notice that, yes that's a much better approach. i'll make a new commit

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

great! I had to look, as it been a long time since I touched this part of the code.

// store them as they might be different on next executor and reset.
gboolean keep_filter = rmpd->keep_filter;
gboolean keep_selection = rmpd->keep_selection;
RofiViewState *state = rofi_view_get_active();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this one is not needed anymore.

}
}

if (state && rmpd->switch_mode >= 0) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

state check is not needed anymore?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep, my bad sorry

@DaveDavenport DaveDavenport merged commit f7adb88 into davatorium:next Sep 24, 2025
7 checks passed
@DaveDavenport
Copy link
Collaborator

Thanks.

@tmoron
Copy link
Contributor Author

tmoron commented Sep 24, 2025

thank you !
btw, I love this project, it's awesome !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants