#!/usr/bin/env bash

RM="/run/current-system/sw/bin/rm"
KILL="/run/current-system/sw/bin/kill"
WLSUNSET="/home/vi/.nix-profile/bin/wlsunset"
ECHO="/run/current-system/sw/bin/echo"
CAT="/run/current-system/sw/bin/cat"
PIDFILE="/tmp/$USER-$EUID-wlsunset.pid"

if [ -e $PIDFILE ]
then
  $KILL $($CAT $PIDFILE)
  $RM $PIDFILE
else
  $WLSUNSET -l 49 -L 9 &
  wlpid=$!
  $ECHO $wlpid > $PIDFILE
fi
