Skip to content

Add GUI Wizard to Create New Timer/Service Units from Scratch #44

@mbnoimi

Description

@mbnoimi

Is your feature request related to a problem? Please describe.

Currently, sysd-manager excels at managing existing systemd units (enable, disable, start, stop, edit, view logs). However, there is no built-in way to create new timer/service unit pairs from scratch through the GUI.

This is a significant gap for users migrating from cron to systemd timers, especially on Xfce desktops where:

  • Traditional cron GUIs (gnome-schedule, zeit) are deprecated/abandoned
  • Users need an accessible way to create scheduled tasks without manual file editing
  • The learning curve for systemd timer syntax is steep for newcomers

Describe the solution you'd like

Add a "Create New Timer" wizard/dialog that guides users through:

Basic Mode (Cron-like experience):

  • Task name (e.g., backup-daily)
  • Command/Script path (with file browser)
  • Schedule type:
    • Calendar-based (daily, weekly, monthly, custom time)
    • Monotonic timer (every X minutes/hours)
  • Run as: User session (--user) or System (root)
  • Persistent: Catch up missed runs after boot (yes/no)

Advanced Mode (Full systemd control):

  • All Basic Mode options plus:
  • Environment variables
  • Working directory
  • Dependencies (After=, Wants=)
  • Resource limits (MemoryMax=, CPUQuota=)
  • Restart policy (on-failure, always, never)
  • StandardOutput/StandardError handling

Expected Output:

The wizard would generate both files automatically:

  • ~/.config/systemd/user/<name>.service (or /etc/systemd/system/)
  • ~/.config/systemd/user/<name>.timer

Then automatically:

  1. Run systemctl --user daemon-reload
  2. Offer to enable and start the timer
  3. Show the new unit in the main browser list

Suggested Implementation Approach:

UI Step 1: Basic Information

Create New Scheduled Task
Step 1 of 4: Basic Information

Task Name *
[backup-daily]
ℹ Will create: backup-daily.service + backup-daily.timer

Task Type
  ● Service + Timer (scheduled task)
  ○ Service Only (manual trigger)
  ○ Timer Only (triggers existing service)

Scope
  ● User Session (~/.config/systemd/user/)
  ○ System-wide (/etc/systemd/system/) [requires authentication]

[Cancel]  [Back]  [Next →]

UI Step 2: Command & Schedule

Create New Scheduled Task
Step 2 of 4: Command & Schedule

Command/Script *
[/home/username/scripts/backup.sh] [Browse...]

Working Directory (optional)
[/home/username] [Browse...]

Schedule Type
  ● Calendar Time (specific times/dates)
  ○ Monotonic Timer (relative intervals)
  ○ Boot Timer (after system startup)

Calendar Presets:
[Every Hour] [Daily] [Weekly] [Monthly]

Custom OnCalendar Expression:
[*-*-* 03:00:00]
ℹ Format: Year-Month-Day Hour:Minute:Second
🔗 https://www.freedesktop.org/software/systemd/man/systemd.time.html

[← Back]  [Next →]

UI Step 3: Advanced Options

Create New Scheduled Task
Step 3 of 4: Advanced Options

Reliability
  [✓] Persistent - Run missed executions after system boot
  [✓] RandomizedDelaySec=5min - Add randomness to prevent storms

Execution
  [ ] Run with root privileges (system units only)
  [ ] Wait for network connection
  [ ] Wait for home directory mount

Resource Limits (optional)
  Memory Max: [512] [MB ▼]
  CPU Quota:  [50]  [%  ▼]

Logging
  Standard Output: [journal ▼]
  Standard Error:  [journal ▼]
  (Options: journal, file, null, inherit)

Environment Variables (optional)
  [+ Add Variable]
  PATH=/usr/bin:/bin
  BACKUP_DEST=/mnt/backup

[← Back]  [Next →]

UI Step 4: Completion & Actions

✓ Timer Created Successfully!

The following units have been created:
  📄 backup-daily.service
  📄 backup-daily.timer

What would you like to do next?
  [✓] Enable timer (start on boot)
  [✓] Start timer immediately
  [ ] View unit files
  [ ] Open logs

[Close]  [Create Another]

Technical Implementation Notes

Component            | Suggestion
---------------------|--------------------------------------------------
Dialog Framework     | Use existing GTK4/libadwaita dialogs
File Writing         | ~/.config/systemd/user/ or /etc/systemd/system/
Validation           | Real-time OnCalendar syntax validation
Name Validation      | Regex: ^[a-zA-Z0-9_-]+$
Command Validation   | Check file exists + executable bit
Daemon Reload        | Auto-trigger systemctl --user daemon-reload
Error Handling       | Show specific systemd error messages
Templates            | Store common presets in JSON config

Service File Template

[Unit]
Description={task_description}
{After=network-online.target if network wait selected}
{Wants=network-online.target if network wait selected}

[Service]
Type=oneshot
ExecStart={command_path}
{WorkingDirectory={working_dir} if specified}
{Environment="VAR=value" for each env var}
{MemoryMax={value} if specified}
{CPUQuota={value}% if specified}
StandardOutput={selection}
StandardError={selection}

[Install]
WantedBy=default.target

Timer File Template

[Unit]
Description=Timer for {task_description}

[Timer]
{OnCalendar={expression} if calendar type}
{OnUnitActiveSec={interval} if monotonic type}
{OnBootSec={interval} if boot timer type}
Persistent={true/false}
RandomizedDelaySec={value if selected}
Unit={name}.service

[Install]
WantedBy=timers.target

Cron Preset Conversions

Preset Name        | OnCalendar Value      | Common Use Case
-------------------|-----------------------|-------------------------
Every Minute       | *:*:*                 | Monitoring, polling
Every Hour         | *:00:00               | Hourly backups, sync
Daily Midnight     | 00:00:00              | Daily backups, cleanup
Daily 3 AM         | 03:00:00              | Off-peak maintenance
Weekly Sunday      | Sun 00:00:00          | Weekly reports
Monthly 1st        | *-01-01 00:00:00      | Monthly billing, reports
Weekdays 9 AM      | Mon..Fri 09:00:00     | Work day tasks
Every 15 Min       | *:*:00/15             | Frequent sync

Integration with Existing Features

Existing Feature     | How Wizard Uses It
---------------------|--------------------------------------------
Unit browser         | New timer appears immediately after creation
Log viewer           | "Open logs" button links to existing viewer
Unit editor          | "View unit files" opens existing editor
Enable/Disable       | Post-creation dialog uses existing toggles
Start/Stop           | Post-creation dialog uses existing controls

Accessibility Checklist

[  ] Keyboard navigation (Tab through fields, Enter to submit)
[  ] Screen reader labels for all form fields
[  ] Clear error messages with field highlighting
[  ] High contrast mode support (follows system GTK theme)
[  ] Tooltips explaining systemd-specific terms

Future Enhancement Ideas

1. Import from Cron - Parse existing crontab entries and convert to timers
2. Export to Cron - Convert timers back to cron format for portability
3. Template Gallery - Community-shared timer configurations
4. Test Run Button - Execute command once before saving to verify it works
5. Notification Integration - Desktop notification on job completion/failure

Summary

Improancement          | Description
-----------------------|--------------------------------------------
4-Step Wizard Flow     | Complete user journey from creation to end
Simple Text Mockups    | Each screen in its own clean text block
Technical Details      | Validation, file paths, error handling
Unit File Templates    | Exact INI format the wizard should generate
Integration Points     | How to reuse existing sysd-manager components
Cron Preset Table      | Ready-to-use OnCalendar conversions

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions