From 5ffd5328dbe8e00718ca229b8a113fd617c5dfd1 Mon Sep 17 00:00:00 2001 From: Katharina Fey Date: Tue, 9 Mar 2021 21:18:38 +0100 Subject: [PATCH] timelapse: initial code dump --- apps/timelapse/.projectile | 0 apps/timelapse/default.nix | 18 ++++++++++++++++++ apps/timelapse/timelapse.rb | 13 +++++++++++++ 3 files changed, 31 insertions(+) create mode 100644 apps/timelapse/.projectile create mode 100644 apps/timelapse/default.nix create mode 100755 apps/timelapse/timelapse.rb diff --git a/apps/timelapse/.projectile b/apps/timelapse/.projectile new file mode 100644 index 00000000000..e69de29bb2d diff --git a/apps/timelapse/default.nix b/apps/timelapse/default.nix new file mode 100644 index 00000000000..8adc4ef0620 --- /dev/null +++ b/apps/timelapse/default.nix @@ -0,0 +1,18 @@ +with import {}; + +stdenv.mkDerivation { + name = "timelapse"; + src = ./.; + + buildInputs = with pkgs; [ ruby gphoto2 ]; + + installPhase = '' + mkdir -p $out/bin + cp timelapse.rb $out/bin/timelapse + ''; + + meta = with lib; { + description = "A small tool to capture timelapse series with gphoto"; + }; +} + diff --git a/apps/timelapse/timelapse.rb b/apps/timelapse/timelapse.rb new file mode 100755 index 00000000000..aa6b6b3106a --- /dev/null +++ b/apps/timelapse/timelapse.rb @@ -0,0 +1,13 @@ +#!/usr/bin/env ruby + +# A function to capture a picture with gphoto2, retrying 3-times in +# case of errors. +def capture_picture + 3.times do + break if `gphoto2 --capture-image` == 0 + puts "Retrying gphoto2 capture..." + end +end + + +capture_picture