@ -25,7 +25,6 @@ var fim *exec.Cmd = nil
var stdin io . WriteCloser = nil
func setupFim ( PATH_TEMP_FOR_SLIDESHOW string ) {
log . Print ( "Setting up new fim process" )
// Prep slideshow command and arguments
// NOTE: The random flag is seeded with time() ; this is bad as we will be restarting the slideshow at about the same time per the configurd schedule
// We use the non-seeded form to ensure that it's a little more random (or at least hope it's a little more random)
@ -57,7 +56,6 @@ func Slideshow(pfconfig *koanf.Koanf) {
// /run is a tmpfs so this won't wear on the sd card storage
// Create temp folder
log . Print ( "Creating temp folder for album selections" )
_ , err := os . Stat ( PATH_TEMP_FOR_SLIDESHOW )
if os . IsNotExist ( err ) {
errDir := os . MkdirAll ( PATH_TEMP_FOR_SLIDESHOW , 0755 )
@ -67,7 +65,6 @@ func Slideshow(pfconfig *koanf.Koanf) {
}
// Cleanup temp folder if it already existed
log . Print ( "Cleaning up temp folder if it exists" )
dirRead , err := os . Open ( PATH_TEMP_FOR_SLIDESHOW )
if err != nil {
log . Fatalf ( "Error setting up slideshow : %s" , err )
@ -93,7 +90,6 @@ func Slideshow(pfconfig *koanf.Koanf) {
// Setup symlinks to selected albums to be used with slideshow
// Add albums full paths to command line args for fim
log . Print ( "Setting up symlinks to selected albums" )
albumRootPath := pfconfig . String ( config . CONFIG_KEY_ALBUMS_ROOT )
for _ , album := range pfconfig . Strings ( config . CONFIG_KEY_ALBUMS_SELECTED ) {
source := albumRootPath + album
@ -131,7 +127,6 @@ func Slideshow(pfconfig *koanf.Koanf) {
setupFim ( PATH_TEMP_FOR_SLIDESHOW )
// Advance slideshow every interval as defined in const()
log . Print ( "Setting up slideshow advance slide ticker" )
slideshowAdvanceDurationString := pfconfig . String ( config . CONFIG_KEY_SLIDESHOW_INTERVAL )
slideshowAdvanceDuration , err := time . ParseDuration ( slideshowAdvanceDurationString )
if err != nil {
@ -172,7 +167,6 @@ func Slideshow(pfconfig *koanf.Koanf) {
STOP_SLIDESHOW := false
// Goroutine for tracking which keys are pressed and controlling fim if appropriate
log . Print ( "Setting up keyboard listener" )
keyboardCtx , keyboardCancel := context . WithCancel ( context . Background ( ) )
go func ( keyboardCtx context . Context ) {
for {
@ -210,7 +204,6 @@ func Slideshow(pfconfig *koanf.Koanf) {
// Control fim if we received a valid key for next/previous slide
if fimKey != "" {
log . Printf ( "Sending key to fim : %s" , fimKey )
_ , err = io . WriteString ( stdin , fimKey )
if err != nil {
log . Fatalf ( "Error controlling fim : %s" , err )
@ -222,7 +215,6 @@ func Slideshow(pfconfig *koanf.Koanf) {
} ( keyboardCtx )
// Restart fim after configured timeout ; This is setup as a ticker due to KemoNine not getting CommandWithContext stuff to work properly (lots of pointer related crashes and the like)
log . Print ( "Setting up fim restart ticker" )
fimRestartDurationString := pfconfig . String ( config . CONFIG_KEY_SLIDESHOW_RESTART_INTERVAL )
fimRestartDuration , err := time . ParseDuration ( fimRestartDurationString )
if err != nil {
@ -251,7 +243,6 @@ func Slideshow(pfconfig *koanf.Koanf) {
// Run fim
for ! STOP_SLIDESHOW {
log . Print ( "Top of fim slideshow loop" )
if err := fim . Run ( ) ; err != nil {
// Unwrap the error a bit so we can find out if a signal killed fim or something else
// An exit code of -1 means the program didn't exit in time or was terminated by a signal (per the docs)