Skip to content

Instantly share code, notes, and snippets.

@toke
Last active March 22, 2017 14:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save toke/db33ca88a69c85f0ce0371089a150181 to your computer and use it in GitHub Desktop.
Save toke/db33ca88a69c85f0ce0371089a150181 to your computer and use it in GitHub Desktop.
Example on how to context switch with systemd - assuming toggling of a target unit.
[Unit]
Description=Laptop at work or in work context
Conflicts=at-home.target
After=graphical.target
[Unit]
Description=bugwarrior-pull
[Service]
Environment="DISPLAY=:0"
ExecStart=/home/toke/.virtualenvs/default/bin/bugwarrior-pull
Type=oneshot
[Install]
WantedBy=at-work.target
[Unit]
Description=Run bugwarrior-pull hourly and on boot
After=at-work.target
PartOf=at-work.target
[Timer]
OnBootSec=15min
OnUnitActiveSec=60m
[Install]
WantedBy=timers.target
WantedBy=at-work.target
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment