21 February 2025

AutoKey (for Linux) script for generating XML tags


# Details
when typing:   something#<
trigger is: "#<"
variable: something

# Actions
1. removes the whole word and types:  <something></something>
2. places the cursor in the middle.

It preserves whatever was on the clipboard.


# Code

```python
import time
#from autokey.scripting import *

import time
#from autokey.scripting import *

trigger = "#<"
original_clipboard = clipboard.get_clipboard()

# Move cursor left to remove the trigger
keyboard.send_keys("<backspace>" * len(trigger))

# Select the whole word
keyboard.send_keys("<ctrl>+<shift>+<left>")
time.sleep(0.1)
keyboard.send_keys("<ctrl>+c")
time.sleep(0.1)

selected_text = clipboard.get_clipboard().strip()

if selected_text:
    keyboard.send_keys(f"<{selected_text}></{selected_text}>")
    # Move cursor inside the tags
    keyboard.send_keys("<left>" * (len(selected_text) + 3))


clipboard.fill_clipboard(original_clipboard)
```

# Trigger setup (this is important as it goes along with the code)




# Demo




Hope it helps.


19 February 2025

Moving the vscode configuration folder to RAM transparently.


Note about my setup: Vscode running on linux, remotely against another linux.


# Context

Moving the vscode configuration folder to RAM transparently.

One way, my chosen one, is using profile-sync-daemon (PSD).

I have used it extensively, with 2 browsers.

PSD is like anything-sync-daemon but specialized in browsers.

However, you can make vscode look like a browser with a few steps.

DISCLAIMER: This may not be what you want, it may not work for you. Anything may happen, even data loss. No backups, no brain.

Note: I have PSD up and running well, so I won't cover that.

# 1. Create conf file for vscode

Each "browser" has a little configuration file for PSD to know what to sync and how to call it. Just that.

In `/usr/share/psd/browsers/` you should see a few files like


```
/usr/share/psd/browsers/epiphany
/usr/share/psd/browsers/firefox
/usr/share/psd/browsers/firefox-trunk
/usr/share/psd/browsers/google-chrome
/usr/share/psd/browsers/google-chrome-beta
/usr/share/psd/browsers/google-chrome-unstable
/usr/share/psd/browsers/heftig-aurora
/usr/share/psd/browsers/icecat
/usr/share/psd/browsers/inox
/usr/share/psd/browsers/luakit
/usr/share/psd/browsers/midori
/usr/share/psd/browsers/opera
/usr/share/psd/browsers/opera-beta
/usr/share/psd/browsers/opera-developer
```


Create one

`# touch /usr/share/psd/browsers/vscode`


# 2. Edit it.

Enter on it and add


```
DIRArr[0]="$XDG_CONFIG_HOME/Code"
PSNAME="vscode"
```


In case you didn't know


```
$ echo $XDG_CONFIG_HOME/Code
/home/<user>/.config/Code
```

Save and exit.


Verify

```
$ cat /usr/share/psd/browsers/vscode
DIRArr[0]="$XDG_CONFIG_HOME/Code"
PSNAME="vscode"
```

# 3. Edit psd configuration


Add your "new browser" to your personal conf file located on `/home/<user>/.config/psd/psd.conf`


```
# Before
# BROWSERS="waterfox google-chrome"
# now : added vscode on 2025-02-19
BROWSERS="waterfox google-chrome vscode"
```

Save file.

Close Browsers and VSCode, fully.


At this stage you may want to do

`$ psd preview`

in case it finds any issue.


```
Profile-sync-daemon v6.31 on Debian GNU/Linux 10 (buster)

 Systemd service is currently active.
 Systemd resync-timer is currently active.
 Overlayfs v23 is currently active.

Psd will manage the following per /home/rgarcia/.config/psd/.psd.conf:

...

```


# 4. Restart the service.


`systemctl --user restart psd.service`


Now verify that vscode is now taken care of.

`$ psd preview`


```
$ psd preview
Profile-sync-daemon v6.31 on Debian GNU/Linux 10 (buster)

 Systemd service is currently active.
 Systemd resync-timer is currently active.
 Overlayfs v23 is currently active.

Psd will manage the following per /home/<user>/.config/psd/.psd.conf:

 [ ... info about browsers ... ]

 browser/psname:  vscode/vscode
 owner/group id:  <user>/1000
 sync target:     /home/<user>/.config/Code
 tmpfs dir:       /run/user/1000/<user>-vscode
 profile size:    143M
 overlayfs size:  0
 recovery dirs:   1 <- delete with the c option
  dir path/size:  /home/<user>/.config/<...>-backup-crashrecovery-20250203_203220 (864M)
```

Done.

You Hard-Drive will be very happy, even if it is SSD.


Too Cool for Internet Explorer