Skip to content

storopoli/dead-man-switch

Repository files navigation

Dead Man's Switch

AGPL-v3 Crates.io docs

This is a simple implementation of a Dead Man's Switch.

Use at your own risk. Check the f****(as in friendly) code.

screenshot

Dead man's switches are designed to require positive action or they will automatically deploy. They are ideal for situations where you are worried about unforeseen death, kidnapping, or memory loss. If you don’t engage the trigger for a certain amount of time, the switch automatically sends the desired message.

Features

  • Simple: Easy to use and setup.
  • Reliable: Implemented in Rust.
  • Minimal: Very few dependencies and needs minimal resources.
  • Warning: Sends a warning email before the final email.
  • Attachments (Optional): Send attachments with the final email.

How it Works

If you want a very simple explanation and the motivation behind the project, check my blog post here.

Upon starting the program it will create a config.toml file in an OS-agnostic config file location:

  • Linux: $XDG_CONFIG_HOME, i.e. $HOME/.config|/home/alice/.config
  • macOS: $HOME/Library/Application Support, i.e. /Users/Alice/Library/Application Support
  • Windows: {FOLDERID_RoamingAppData}, i.e. C:\Users\Alice\AppData\Roaming

Edit the config.toml file to your liking. Some default values are provided for inspiration.

Dead Man's Switch comprises of two timers:

  1. Warning Timer: This timer is set to the timer_warning (seconds) value in the config.toml file. If the user do not check-in before timer reaches 0, it will send a warning email to the users' own specified email address, the from in the config.toml.
  2. Dead Man's Timer: After the warning timer expires, the timer will change to a Dead Man's timer, and the timer will be set to the timer_dead_man (seconds). If the user do not check-in before timer reaches 0, it will send the final email to the specified email address in the config.toml, i.e. the to in the config.toml.

If you want to send attachments with the Dead Man's email, you can specify the attachments option config in the config.toml and provide the absolute path to the file you want to attach.

To check-in, you just need to press the c key as in check-in.

Installation

There are several ways to install Dead Man's Switch:

  1. Crates.io: cargo install dead-man-switch.

  2. GitHub: cargo install --git https://github.com/storopoli/dead-man-switch.

  3. From source: Clone the repository and run cargo install --path ..

  4. Using Nix: nix run github:storopoli/dead-man-switch.

  5. Using Nix Flakes: add this to your flake.nix:

    {
      # ...
      inputs.dead-man-switch = {
        url = "github:storopoli/neovix";
        inputs = {
          nixpkgs.follows = "nixpkgs";
          flake-parts.follows = "flake-parts";
        };
      };
    
      outputs = inputs @ { self, ... }:
      {
        imports = [
          {
            nixpkgs.overlays = [
              # ...
              inputs.dead-man-switch.overlays.default
            ];
          }
        ];
      };
    
    }

    Then dead-man-switch will be available as pkgs.dead-man-switch;

Minimum Supported Rust Version

This crate uses current Debian stable Rust version as Minimum Supported Rust Version (MSRV). Please check Debian's rustc package for more details.

Currently, the MSRV is 1.63.0.

License

The source code is licensed under an AGPL v3 License

AGPL-v3