Can Autokey source a folder saved on Dropbox, for all syncing **all** settings across machines?

267 views
Skip to first unread message

Linfeng Li

unread,
Feb 16, 2020, 10:31:18 PM2/16/20
to autokey-users
Dear group,

First, I am a bit confused by how Autokey sources its settings. In particular, are actions (through scripts.py) stored separately from the "conditions"? And, are there examples that I can store conditions along with the actions, and have AutoKey source this script?

Through the autokey-gtk interface (0.95.10), I can create new scripts and assign conditions for it. One example is to "remap" the ctrl+q key-combination for ctrl+w. In order to achieve this purpose, I need to:
  • Specify the window filter condition (for Navigator.Firefox) and the Hotkey condition (<ctrl>+q);
  • Write up a one-liner script, with: "keyboard.send_keys("<ctrl>+w")
Then, I am left wondering: how were the two pieces stored, separately?

In general, with AutoHotKey, I have been reusing one single AHK_Master.ahk file (while having it sourcing a few other helper scripts) through Dropbox across multiple Windows machines. With other Windows+AutoHotKey tricks, I can get the scripts on multiple Windows machines to "sync" semi-automatically (not full-automation as I needed to make sure Dropbox clients on these Windows machines are kept alive).

Per this post, I would like to look for advice on getting one (or a few) full "conditional" mappings to be synced across multiple machines through Dropbox.

Thanks a lot!

All the best,

-Linfeng

Keith Bainbridge

unread,
Feb 16, 2020, 11:41:32 PM2/16/20
to autoke...@googlegroups.com
Have you looked into sym-linking your .config/autokey/ directory to
those several machines? The nearest I have gone is sym-linking into
virtual machices. Also, I have several config type files (including
autokey) stored on a data partition and sym-linked into my home - makes
multi booting easier.

Keith Bainbridge

keith.bain...@gmail.com
0447 667 468

On 17/2/20 2:31 pm, Linfeng Li wrote:
> Dear group,
>
> First, I am a bit confused by how Autokey sources its settings. In
> particular, *are actions (through scripts.py) stored separately from the
> "conditions"*? And, are there examples that I can store conditions along
> with the actions, and have AutoKey source this script?
>
> Through the autokey-gtk interface (0.95.10), I can create new scripts
> and assign conditions for it. One example is to "remap" the *ctrl+q
> *key-combination for *ctrl+w*. In order to achieve this purpose, I need to:
>
> * Specify the *window filter condition* (for Navigator.Firefox) and
> the *Hotkey* /condition/ (<ctrl>+q);
> * Write up a one-liner script, with: "keyboard.send_keys("<ctrl>+w")
>
> Then, I am left wondering: how were the two pieces stored, separately?
>
> In general, with AutoHotKey, I have been reusing one single
> AHK_Master.ahk file (while having it sourcing a few other helper
> scripts) through Dropbox across multiple Windows machines. With other
> Windows+AutoHotKey tricks, I can get the scripts on multiple Windows
> machines to "sync" semi-automatically (not full-automation as I needed
> to make sure Dropbox clients on these Windows machines are kept alive).
>
> Per this post, I would like to look for advice on getting one (or a few)
> full "conditional" mappings to be /synced/ across multiple machines
> through Dropbox.
>
> Thanks a lot!
>
> All the best,
>
> -Linfeng
>
> --
> You received this message because you are subscribed to the Google
> Groups "autokey-users" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to autokey-user...@googlegroups.com
> <mailto:autokey-user...@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/autokey-users/6728e5be-0677-451c-8a3c-3498a733d26c%40googlegroups.com
> <https://groups.google.com/d/msgid/autokey-users/6728e5be-0677-451c-8a3c-3498a733d26c%40googlegroups.com?utm_medium=email&utm_source=footer>.

Linfeng Li

unread,
Feb 17, 2020, 12:03:24 AM2/17/20
to autokey-users
Please advise if there are other places check for settings for conditional-hotkeys: I first got Autokey on the test-machine from the App Store of Pop OS and found it to be outdated. Then, I deleted it and installed through the latest gtk.deb installer. Yet, in my ~/.config/autokey directory, I did not find anything that specified a few of the conditional mappings that I have defined for Firefox windows.

RE: sym-link - I was warned against sym-linking files from/to Dropbox by Dropbox support people. They said it would mess up Dropbox clients.

Does Autokey have any of the "sourcing feature"? For my dotfiles for the shell, source $HOME/Dropbox/some_dir/some_sh does the job of identifying where the shared settings are located. Across multiple machines, I kept a physical copy of the dotfiles on the hard-drive through Dropbox, and only adjust the $HOME variable through the local ~/.bashrc.

When I attempt to "add an existing folder" to AutoKey-gtk, through the "New/Folder" menu item, the folder was added but not any of its nested folder nor files. I was doubting if this is the intended behavior as well.



On Sunday, February 16, 2020 at 11:41:32 PM UTC-5, Keith Bainbridge wrote:
Have you looked into sym-linking your .config/autokey/ directory to
those several machines?   The nearest I have gone is sym-linking into
virtual machices. Also, I have several config type files (including
autokey) stored on a data partition and sym-linked into my home - makes
multi booting easier.

Keith Bainbridge

Joe

unread,
Feb 17, 2020, 8:34:40 AM2/17/20
to autoke...@googlegroups.com
Hi.

There "should" be no problem using Dropbox with AutoKey. To Dropbox, the
AutoKey files are just plain text files.

Several points:

1) Each AutoKey phrase and script consists of two files, a file
containing the body of the script or phrase and a sidecar file
containing the metadata for the script or phrase. You have to make sure
you copy/move the pairs together or they will not work.

Scripts: my_script.py / .my_script.json

Phrases: my_phrase.txt / .my_phrase.json

Because the metadata file names start with a dot, they are hidden files
by default and some copy commands like cp will miss them by default.
rsync will get them.

I have filed an enhancement request to unhide these files because we get
questions/problems like this all the time. The developers think it's a
good idea, but I don't believe it has been worked on yet.

An artifact of this scheme and of the way Linux works is that you cannot
name any of your phrases/scripts with a dot as the first character of
the name. It won't break anything, but they won't work either.

2) Prior to 0.95.10, AutoKey didn't bother to check if a folder already
exists when you created it in the AutoKey Main window. This would
effectively delete everything in that folder.

Hopefully, that has been fixed, but always make a backup of all your
hard work before proceeding with this sort of file management.

3) After you add or delete script/phrase files manually from outside of
AutoKey, they should be functional immediately. But, since AutoKey does
not watch its directories, the changes will not show up in the main
window until you quit and restart AutoKey. (They may not be available
before restarting AutoKey, but we don't have a test case where they are
not, so it hasn't been looked into yet.)

4) When you create a new folder from within AutoKey, it allows you to
provide a path to the folder, so it  can be anywhere. If your regular
user account that AutoKey is running under has read/write access to the
files, AutoKey will be able to use them.

AutoKey needs to be able to write to these files in the obvious cases
such as when you edit the body of a phrase or script from within AutoKey
and also when you change any of the associated metadata such as the
hotkey, trigger phrase, or window filter.

The part I'm not sure of is that there may be one or more statistical
fields that get written when a phrase/script is just used. It looks like
usageCount counts how many times the phrase/script has been invoked. In
a single user setup, this is a non-issue, but if you are sharing your
configuration between multiple concurrent users using something like
Dropbox, it might be possible for two processes to attempt to update a
file at the same time with unpredictable results. If usageCount gets the
wrong value, nobody probably cares. I'm not even sure if it gets used.
But, if the file gets corrupted, that's another story. If you use this
personally so that you are only actively using one instance of AutoKey
at a time, there shouldn't be an issue. I will follow up on this with
the developers.

5) As for the subfolder issue, that "should" be up to Linux which is
perfectly comfortable with such things. If you can produce a test case
of a failure with this, I would guess that fixing it would have a pretty
high priority.

6) A way you can use symlinks is to put one or more of them in your
local $HOME/.config/autokey directory tree. They could point to things
anywhere, including in Dropbox, because Dropbox won't even know the
symlinks exist.

7) The old way of doing things that works (if there are still bugs in
AutoKey with respect to folders.) :

Go into AutoKey and create a new folder with the name you want and
nothing in it. It can have any path you like as long as it is all user
read/write (and execute for any directories involved.)
From outside of AutoKey, copy your new subdirectory tree of scripts and
phrases into the one you just created from within AutoKey.
Restart AutoKey.

I have been doing this for years and it works fine. I store all my
scripts and phrases in a folder subtree outside of $HOME/.config/autokey.

This has a couple of side benefits. If I reinstall or even purge
AutoKey, all of my phrases and scripts are completely safe. They are
also more convenient to access for editing and making backups.

8) Script/phrase metadata is stored as relatively simple, line-oriented,
human-readable json text files. They can be hand edited or created en
masse by scripts.

I wrote a proof-of-concept bash script which converts AutoHotKey phrases
to AutoKey phrases. It's proof-of-concept because it only converts a
couple of the many parameters AutoHotKey supports and because it only
handles single-line phrases. Available upon request. (I am open to
developing it further, time permitting, but I know nothing about
AutoHotKey.)

Joe

On 2/17/20 12:03 AM, Linfeng Li wrote:
> Please advise if there are other places check for settings for
> conditional-hotkeys: I first got Autokey on the test-machine from the
> App Store of Pop OS and found it to be outdated. Then, I deleted it
> and installed through the latest gtk.deb installer. Yet, in my
> *~/.config/autokey *directory, I did not find anything that specified
> a few of the /conditional mappings/ that I have defined for Firefox
> windows.
>
> RE: sym-link - I was warned against sym-linking files from/to Dropbox
> by Dropbox support people. They said it would mess up Dropbox clients.
>
> Does Autokey have any of the "sourcing feature"? For my dotfiles for
> the shell, *source $HOME/Dropbox/some_dir/some_sh* does the job of
> identifying where the shared settings are located. Across multiple
> machines, I kept a physical copy of the dotfiles on the hard-drive
> through Dropbox, and only adjust the $HOME variable through the local
> ~/.bashrc.
>
> When I attempt to "add an existing folder" to AutoKey-gtk, through the
> "New/Folder" menu item, the folder was added but not any of its nested
> folder nor files. I was doubting if this is the intended behavior as well.
>
>
>
> On Sunday, February 16, 2020 at 11:41:32 PM UTC-5, Keith Bainbridge
> wrote:
>
> Have you looked into sym-linking your .config/autokey/ directory to
> those several machines?   The nearest I have gone is sym-linking into
> virtual machices. Also, I have several config type files (including
> autokey) stored on a data partition and sym-linked into my home -
> makes
> multi booting easier.
>
> Keith Bainbridge
>
> keith.bai...@gmail.com <javascript:>
> > an email to autoke...@googlegroups.com <javascript:>
> > <mailto:autokey-user...@googlegroups.com <javascript:>>.
> <https://groups.google.com/d/msgid/autokey-users/6728e5be-0677-451c-8a3c-3498a733d26c%40googlegroups.com?utm_medium=email&utm_source=footer
> <https://groups.google.com/d/msgid/autokey-users/6728e5be-0677-451c-8a3c-3498a733d26c%40googlegroups.com?utm_medium=email&utm_source=footer>>.
>
>
> --
> You received this message because you are subscribed to the Google
> Groups "autokey-users" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to autokey-user...@googlegroups.com
> <mailto:autokey-user...@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/autokey-users/55c33cdb-ebe2-4383-add6-a85bc1685d74%40googlegroups.com
> <https://groups.google.com/d/msgid/autokey-users/55c33cdb-ebe2-4383-add6-a85bc1685d74%40googlegroups.com?utm_medium=email&utm_source=footer>.

Linfeng Li

unread,
Feb 18, 2020, 9:20:59 PM2/18/20
to autokey-users
Hi Joe,

Thank you for clarifying how things are stored and sourced by Autokey. To reiterate what you have said:
  • In Autokey, each script.py contains one action (or a sequence of actions). The condition that triggers the script is named as .script.json, which is human-readable;
  • Autokey does not monitor folders actively. One can add local folders as needed (be it a local ~/.config/AutoKey/XXX folder or a Dropbox folder). Only upon "restart" will AutoKey source whatever was stored in the newly "added" folders.
Is there a sample script that can "reload" the entire AutoKey session/process? For now, with external changes to the "source script folder", say, through Dropbox, I find it necessary to quit the AutoKey process by hand, and re-open it. I guess a quick Python script that executes a shell-script can get the job done?

Based on my AutoHotKey experience, it has now been muscle memory to reload the script (or, for AutoKey, the "active session?") by pressing Ctrl + Shift + Alt + R. I would like to get this mapping realized for AutoKey to speed up my syncing and testing process.

Thanks again!

All the best,

-Linfeng
>     > <mailto:autokey-users+unsub...@googlegroups.com <javascript:>>.

Joe

unread,
Feb 19, 2020, 9:52:03 AM2/19/20
to autoke...@googlegroups.com
That's an interesting problem.

My first thought is:

Write a bash script:

#!/bin/bash
pkill autokey
sleep 1
autokey-gtk &

That would kill it and restart it..

Write an AutoKey script to run the above bash script (using subprocess()
) and bind it to your selected hotkey.

But: This is having AutoKey run a script which kills AutoKey.

It may work, but I would test it a lot before putting it into general use.

I'm going to mention this on Gitter and see what the devs say.

Joe

On 2/18/20 9:20 PM, Linfeng Li wrote:
> Hi Joe,
>
> Thank you for clarifying how things are *stored *and *sourced by
> Autokey. *To reiterate what you have said:
>
> * In Autokey, each *script.py* contains one action (or a sequence of
> actions). The condition that triggers the script is named as
> *.script.json*, which is human-readable;
> * Autokey does not monitor folders actively. One can *add *local
> folders as needed (be it a local ~/.config/AutoKey/XXX folder or a
> Dropbox folder). *Only upon "restart" will AutoKey source whatever
> was stored in the newly "added" folders.*
> >     > <mailto:autokey-user...@googlegroups.com
> <javascript:> <javascript:>>.
> > an email to autoke...@googlegroups.com <javascript:>
> > <mailto:autokey-user...@googlegroups.com <javascript:>>.
> > To view this discussion on the web visit
> >
> https://groups.google.com/d/msgid/autokey-users/55c33cdb-ebe2-4383-add6-a85bc1685d74%40googlegroups.com
> <https://groups.google.com/d/msgid/autokey-users/55c33cdb-ebe2-4383-add6-a85bc1685d74%40googlegroups.com>
>
> >
> <https://groups.google.com/d/msgid/autokey-users/55c33cdb-ebe2-4383-add6-a85bc1685d74%40googlegroups.com?utm_medium=email&utm_source=footer
> <https://groups.google.com/d/msgid/autokey-users/55c33cdb-ebe2-4383-add6-a85bc1685d74%40googlegroups.com?utm_medium=email&utm_source=footer>>.
>
>
> --
> You received this message because you are subscribed to the Google
> Groups "autokey-users" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to autokey-user...@googlegroups.com
> <mailto:autokey-user...@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/autokey-users/d2c0d389-6765-42fe-bfb1-0e8cbeff2986%40googlegroups.com
> <https://groups.google.com/d/msgid/autokey-users/d2c0d389-6765-42fe-bfb1-0e8cbeff2986%40googlegroups.com?utm_medium=email&utm_source=footer>.

Linfeng Li

unread,
Feb 19, 2020, 10:00:03 AM2/19/20
to autokey-users
I do share the same initial impression as well: it would be an overkill to have
AutoKey "kill" itself and "revive" itself within the next few milliseconds :)

As I discovered recently, after setting up AutoKey to source a shared Dropbox
folder, it shall quietly load remote changes. This works the best without the
GUI window opened. The only "real" need for the kill-and-revive script is
actually a one-shot thing: it was necessary to "kill" AutoKey after adding a new
folder to it, as only after a reboot will AutoKey start reading things in the
newly added folder.

Personally, I can bear with this manual set-up process, as I was also installing
AutoKey manually.

>     >     > <mailto:autokey-users+unsub...@googlegroups.com
>     <javascript:> <javascript:>>.
>     >     > To view this discussion on the web visit
>     >     >
>     >    
>     https://groups.google.com/d/msgid/autokey-users/6728e5be-0677-451c-8a3c-3498a733d26c%40googlegroups.com
>     <https://groups.google.com/d/msgid/autokey-users/6728e5be-0677-451c-8a3c-3498a733d26c%40googlegroups.com>
>
>     >    
>     <https://groups.google.com/d/msgid/autokey-users/6728e5be-0677-451c-8a3c-3498a733d26c%40googlegroups.com
>     <https://groups.google.com/d/msgid/autokey-users/6728e5be-0677-451c-8a3c-3498a733d26c%40googlegroups.com>>
>
>     >
>     >     >
>     >    
>     <https://groups.google.com/d/msgid/autokey-users/6728e5be-0677-451c-8a3c-3498a733d26c%40googlegroups.com?utm_medium=email&utm_source=footer
>     <https://groups.google.com/d/msgid/autokey-users/6728e5be-0677-451c-8a3c-3498a733d26c%40googlegroups.com?utm_medium=email&utm_source=footer>
>
>     >    
>     <https://groups.google.com/d/msgid/autokey-users/6728e5be-0677-451c-8a3c-3498a733d26c%40googlegroups.com?utm_medium=email&utm_source=footer
>     <https://groups.google.com/d/msgid/autokey-users/6728e5be-0677-451c-8a3c-3498a733d26c%40googlegroups.com?utm_medium=email&utm_source=footer>>>.
>
>     >
>     >
>     > --
>     > You received this message because you are subscribed to the Google
>     > Groups "autokey-users" group.
>     > To unsubscribe from this group and stop receiving emails from
>     it, send
>     > an email to autoke...@googlegroups.com <javascript:>
>     > <mailto:autokey-users+unsub...@googlegroups.com <javascript:>>.
Reply all
Reply to author
Forward
0 new messages