Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API access to more of the abbreviation properties for a phrase, when using engine.create_phrase #917

Open
4 of 16 tasks
stibinator opened this issue Oct 11, 2023 · 3 comments
Labels
enhancement help-wanted scripting Issues related to Scripts or the scripting API

Comments

@stibinator
Copy link

stibinator commented Oct 11, 2023

AutoKey is a Xorg application and will not function in a Wayland session. Do you use Xorg (X11) or Wayland?

X11

Has this issue already been reported?

  • I have searched through the existing issues.

Is this a question rather than an issue?

  • This is not a question.

What type of issue is this?

Enhancement

Choose one or more terms that describe this issue:

  • autokey triggers
  • autokey-gtk
  • autokey-qt
  • beta
  • bug
  • critical
  • development
  • documentation
  • enhancement
  • installation/configuration
  • phrase expansion
  • scripting
  • technical debt
  • user interface

Other terms that describe this issue if not provided above:

No response

Which Linux distribution did you use?

Ubuntu 22.04.3 LTS / Gnome

Which AutoKey GUI did you use?

GTK

Which AutoKey version did you use?

No response

How did you install AutoKey?

pip3

Can you briefly describe the issue?

I'm modifying the Abbreviation from selection script, and want to make the scripts it creates have the abbreviation.immediate = True. There doesn't seem to be a way to do this with the API. It would be good if you could set all the abbreviation properties, like backspace, ignoreCase, triggerInside etc from the engine.create_phrase() method.

Can the issue be reproduced?

Always

What are the steps to reproduce the issue?

No response

What should have happened?

No response

What actually happened?

No response

Do you have screenshots?

No response

Can you provide the output of the AutoKey command?

No response

Anything else?

No response

@josephj11
Copy link
Contributor

Welcome to the AutoKey community, @stibinator !

If AutoKey functions in general for you, then you are using X11. Wayland breaks a lot of the current functionality of AutoKey. (We have a new version that mostly works with Wayland in alpha testing.)

Until this enhancement gets implemented, you should be able write some code to directly edit the newly created metadata files (your_script_name.json or your_phrase_name.json) to "manually" modify the fields you need to set. They're plain text JSON files, so any language capable of text processing such as sed will serve. You can probably do this directly in Python in the script that creates the new action. If you write it as a separate script/function, you can store it in the AutoKey Modules folder and import it into your scripts that need it. This will work because the function doesn't require any AutoKey API calls which are tricky to access from scripts in the Modules directory.

@josephj11 josephj11 added enhancement help-wanted scripting Issues related to Scripts or the scripting API labels Oct 11, 2023
@stibinator
Copy link
Author

Ok. Is there a way to get the path to the newly created script in the API?

@josephj11
Copy link
Contributor

I haven't used this facility at all, so IDK for sure.

Looked at 0.96.0 docs at https://autokey.github.io/api/engine.html create_phrase(). The first argument is the folder to use, so you should know the path to start with. Keep in mind that there will always be two files - your_phrase.txt and your_phrase.json. As of 0.96.0, the metadata (.json) files are no longer hidden files, so they are easier to find and manage.

If you're not clear where a phrase was stored, you can create one and search for it using find from the CLI... If you're not doing anything to explicitly specify an external folder, all AutoKey actions will be stored somewhere under $HOME/.config/autokey/data.

BTW, we don't see this feature getting used a lot, so anything you'd like to add to our wiki about your use case would be appreciated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement help-wanted scripting Issues related to Scripts or the scripting API
Projects
None yet
Development

No branches or pull requests

2 participants