--- /dev/null
+#!/bin/bash
+SANE_DEFAULT_DEVICE="epsonscan2:EPSON Scanner:001:011:esci2:usb:ES00EB:315"
+export SANE_DEFAULT_DEVICE
+scans=$(ls -1 scan*.jpg | wc -l)
+
+if [ "$1" == "1" ] || [ "$1" == "en" ]; then
+ echo "Scanner ett bilde og avslutter, pass på at bildet er plassert oppe til høyre med ca. 1 cm klaring til kantene."
+ ((scans++))
+ file1=$(printf %03d $scans)
+ if scanimage -x 165 -y 115 --mode Color --resolution=1200 --format=tiff > /tmp/temp.tiff; then
+ echo "Scanning ferdig, konverterer til jpeg"
+ convert /tmp/temp.tiff "scan-${file1}.jpg"
+ echo "Lagret scan-${file1}.jpg"
+ rm /tmp/temp.tiff
+ else
+ echo "Scanning feilet, prøv igjen."
+ exit 1
+ fi
+else
+ echo "Automatisk scanning av to bilder om gangen, pass på at bildene er plassert oppe til høyre med ca. 1 cm klaring fra kantene."
+ while true; do
+ ((scans++))
+ file1=$(printf %03d $scans)
+ ((scans++))
+ file2=$(printf %03d $scans)
+ echo "Starter scanning …"
+ if scanimage -x 165 -y 230 --mode Color --resolution=1200 --format=tiff > /tmp/temp.tiff; then
+ echo "Scanning ferdig, lagrer bilder"
+ convert -chop 0x5200+0+0 -gravity South /tmp/temp.tiff "scan-${file1}.jpg"
+ echo "Lagret scan-${file1}.jpg"
+ convert -chop 0x5000+0+0 /tmp/temp.tiff "scan-${file2}.jpg"
+ echo "Lagret scan-${file2}.jpg"
+ rm /tmp/temp.tiff
+ else
+ echo "Scanning feilet, prøv igjen."
+ exit 1
+ fi
+ read -p "Trykk enter for å scanne igjen, eller ctrl+C for å avslutte"
+ done
+fi
--- /dev/null
+#!/bin/bash
+# Script to control and query a connected screen
+# For infoscreen purposes
+# Tries to use cec-client and falls back to DPMS
+# Usage: ./screencontrol.sh [query | on | off]
+
+export DISPLAY=:0
+if [ -z "${1}" ]; then
+ set -- "query"
+fi
+
+if [ "${1}" == "query" ]; then
+ if status=$(echo "pow 0" | cec-client -s -d 1); then
+ if [[ ${status} =~ (power status: on) ]]; then
+ echo "Screen is on"
+ else
+ echo "Screen is off"
+ fi
+ else
+ if status=$(xset q); then
+ if [[ ${status} =~ (Monitor is Off) ]]; then
+ echo "Screen is off"
+ else
+ echo "Screen is on"
+ fi
+ else
+ echo "Unable to determine status of screen"
+ exit 1
+ fi
+ fi
+elif [ "${1}" == "on" ]; then
+ if echo "on 0" | cec-client -s -d 1 >/dev/null; then
+ xset s off
+ xset s noblank
+ xset -dpms
+ echo "Screen turned on (CEC)"
+ else
+ if xset dpms force on; then
+ xset s off
+ xset s noblank
+ xset -dpms
+ echo "Screen turned on (DPMS)"
+ else
+ echo "Unable to turn screen on"
+ exit 1
+ fi
+ fi
+elif [ "${1}" == "off" ]; then
+ if echo "standby 0" | cec-client -s -d 1 >/dev/null; then
+ echo "Screen turned off (CEC)"
+ else
+ if xset dpms force off; then
+ echo "Screen turned off (DPMS)"
+ else
+ echo "Unable to turn screen off"
+ fi
+ fi
+else
+ echo "Error: Unknown command"
+ exit 1
+fi
--- /dev/null
+#!/usr/bin/python3
+from suncalc import get_position, get_times
+from datetime import datetime, timedelta, date
+
+debug = False
+#debug = True
+
+now = datetime.now()
+#now = datetime(2023, 12, 13, 0, 0)
+date = now.replace(hour=12, minute=0, second=0, microsecond=0)
+
+lon = 10.71
+lat = 60.772
+height = 100
+
+sun = get_times(date, lon, lat, height)
+
+if type(sun["nautical_dawn"]) is datetime:
+ sunup = sun["nautical_dawn"] + timedelta(hours=1)
+else:
+ sunup = now
+if type(sun["nautical_dusk"]) is datetime:
+ sundown = sun["nautical_dusk"] + timedelta(hours=1)
+else:
+ sundown = now + timedelta(hours=23, minutes=59, seconds=50)
+
+# If sunup is in the future
+if now < sunup:
+ countdown = (sunup - now).total_seconds()
+ countdown_read = sunup - now
+ duration = (sundown - sunup).total_seconds() * 1000
+ duration_read = sundown - sunup
+else:
+ countdown = 0
+ countdown_read = 0
+ duration = (sundown - now).total_seconds() * 1000
+ duration_read = sundown - now
+
+if int(duration) < 0:
+ print("Sun already set, fool")
+ exit(1)
+
+if debug:
+ print(" Now is ", now)
+ print(" Date is ", date)
+ print(" Sun up is ", sunup)
+ print(" Sun down is ", sundown)
+ print("Countdown is ", countdown_read)
+ print(" Duration is ", duration_read)
+ print("")
+
+print(int(countdown), int(duration), sep='\t')