Hacker News new | ask | show | jobs
by anon4 4073 days ago
Implementation for Linux:

    #!/bin/bash
    set -e
    while true; do
        sleep 20m
        xlock -allowaccess&
        pid=$!
        sleep 20s
        kill $pid
    done
Check the manpage for xlock and choose a screensaver that won't keep you looking at the monitor.
3 comments

If you're using Xscreensaver instead of xlock:

    #!/usr/bin/env bash
    set -e
    while true; do
        sleep 20m
        xscreensaver-command -activate
        sleep 20s
        xscreensaver-command -deactivate
    done
This presumes that xscreensaver is configured to have a delay before it is locked (and thus requiring a password to unlock - as would happen if we used `xscreensaver-command -lock`).
I accidentally did something similar quite a few years ago when I stupidly set up a grep to run updatedb every two hours. There was several months lag as well between when I did that and my computer started locking up every two hours for a few minutes. And embarrassingly, it took me a week or two to put it together.
*stupidly set up a cron
Explanation? DOes it just lock the screen for 20 secs?