Script and systemd user service that pre-load strings into CopyQ (and the desktop clipboard history) right after login.
- Linux desktop with systemd user services enabled.
copyqinstalled (on Fedora:sudo dnf install -y copyq).
Create ~/.config/auto-inject-clipboard/strings.txt (the directory will be created if it does not exist). Each line represents one clipboard item. Empty lines and lines starting with # are ignored.
Example:
# Sample entries
Account A
Account B
Temporary password
Copy the script to /usr/local/bin and make it executable:
sudo install -m 0755 auto_inject_clipboard /usr/local/bin/auto_inject_clipboard
Copy the unit file into ~/.config/systemd/user and enable the service:
mkdir -p ~/.config/systemd/user
cp auto_inject_clipboard.service ~/.config/systemd/user/
systemctl --user daemon-reload
systemctl --user enable --now auto_inject_clipboard.service
The service is Type=oneshot: after running it becomes inactive (dead), but the clipboard has already been populated.
systemctl --user status auto_inject_clipboard.service
journalctl --user -u auto_inject_clipboard.service -e -n 50
copyq list
Use Super + V on GNOME or the Klipper clipboard history on KDE to check that entries were added.
- Edit
~/.config/auto-inject-clipboard/strings.txt, then run:
systemctl --user restart auto_inject_clipboard.service
- When you modify the script or service, update the files in the repo and repeat the install steps.
- The script starts CopyQ if it is not already running. If the first clipboard entry is missing in desktop history, increase the delay
ExecStartPrein the service or adjust thesleepinside the script. - To use a different config file, change the
CONFIG_FILEvariable in the script before installation.