Skip to content

Add CLI flags, external blocklist, and GTK frontend#4

Open
orkolorko wants to merge 1 commit into
moron6554:mainfrom
orkolorko:main
Open

Add CLI flags, external blocklist, and GTK frontend#4
orkolorko wants to merge 1 commit into
moron6554:mainfrom
orkolorko:main

Conversation

@orkolorko

Copy link
Copy Markdown

Summary

  • New CLI flags on distractions--.sh (--duration, --preset, --sites, --yes, --no-gui) so the script can be driven non-interactively. The default zenity flow is unchanged.
  • Domain lists moved out into a sibling blocklists.txt (INI-style [social] / [adult] / [timewasters] sections); embedded fallback kept so the script still runs standalone if the file is missing.
  • New distractions_gui.py — a PyGObject/GTK3 frontend that runs unprivileged and shells out via pkexec --no-gui, parsing PROGRESS:<pct>:<msg> lines into a progress bar. Includes an embedded blocklist editor and a live countdown view that polls /var/lib/hardblock/end_time.
  • The hosts / chattr / systemd / at block-setup body is byte-identical — only extracted into a do_block_setup() function so both the zenity progress pipe and the no-gui stdout path can share it. The irreversibility guarantee is preserved.

--no-gui implies --yes, suppresses every zenity dialog, and skips the optional yad countdown (wrappers are expected to render their own). Errors go to stderr as ERROR: <title>: <message>.

Test plan

  • bash -n distractions--.sh — syntax check
  • sudo ./distractions--.sh — confirm the existing interactive zenity flow is unchanged
  • sudo ./distractions--.sh --no-gui --duration 1m --preset social --yes — non-interactive activation; verify PROGRESS: lines on stdout and that the block lifts after 1 minute
  • ./distractions_gui.py — GTK form → polkit prompt → activation → countdown view
  • Edit blocklists.txt (or use the GUI's "Edit list..." button), then activate; verify the new domains end up in /etc/hosts
  • Delete blocklists.txt and run again; verify the embedded fallback still works

🤖 Generated with Claude Code

distractions--.sh: new --duration/--preset/--sites/--yes/--no-gui flags
(default zenity flow unchanged). --no-gui suppresses dialogs, implies
--yes, and emits PROGRESS:<pct>:<msg> lines on stdout for wrappers.
Domains now loaded from blocklists.txt (INI sections, embedded fallback).
Block-setup body factored into do_block_setup(); the hosts/chattr/
systemd/at calls are byte-identical.

distractions_gui.py: PyGObject/GTK3 frontend, runs unprivileged, shells
out via pkexec --no-gui. Includes an embedded blocklist editor and a
live countdown view that polls /var/lib/hardblock/end_time.

CLAUDE.md: documents the layered architecture and wrapper protocol.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant