Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
K
kiosk
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
don
kiosk
Commits
2d39a895
Commit
2d39a895
authored
6 years ago
by
don
Browse files
Options
Downloads
Patches
Plain Diff
Major revision to add config file, multiple slide sets, variable timing
parent
44991f49
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
bin/process-conf
+4
-0
4 additions, 0 deletions
bin/process-conf
bin/run
+139
-88
139 additions, 88 deletions
bin/run
bin/show
+6
-2
6 additions, 2 deletions
bin/show
config-syntax
+0
-16
0 additions, 16 deletions
config-syntax
loop
+8
-0
8 additions, 0 deletions
loop
with
157 additions
and
106 deletions
bin/process-conf
0 → 100755
+
4
−
0
View file @
2d39a895
#!/bin/sh
cd
/home/pi/kiosk/content
libreoffice
--headless
--convert-to
csv conf.xlsx
/bin/mv
-f
conf.csv ..
This diff is collapsed.
Click to expand it.
bin/run
+
139
−
88
View file @
2d39a895
...
...
@@ -2,12 +2,16 @@
import
magic
,
os
,
pickle
,
re
,
subprocess
basedir
=
'
/home/pi/kiosk
'
remote
=
'
Kiosks:Kiosks/Testing
'
statusfile
=
os
.
path
.
join
(
basedir
,
'
state/statusfile
'
)
contentdir
=
os
.
path
.
join
(
basedir
,
'
content
'
)
slidedir
=
os
.
path
.
join
(
basedir
,
'
slides
'
)
tmpdir
=
os
.
path
.
join
(
basedir
,
'
tmp
'
)
synccommand
=
[
'
/usr/bin/rclone
'
,
'
sync
'
,
remote
,
contentdir
]
remote
=
'
Kiosks:Kiosks/Test2
'
statusfile
=
os
.
path
.
join
(
basedir
,
'
state
'
,
'
statusfile
'
)
contentbase
=
os
.
path
.
join
(
basedir
,
'
content
'
)
slidebase
=
os
.
path
.
join
(
basedir
,
'
slides
'
)
tmpdir
=
os
.
path
.
join
(
basedir
,
'
tmp
'
)
loopfile
=
os
.
path
.
join
(
basedir
,
'
loop
'
)
looptmp
=
os
.
path
.
join
(
basedir
,
'
loop.tmp
'
)
confcsv
=
os
.
path
.
join
(
basedir
,
'
conf.csv
'
)
synccommand
=
[
'
/usr/bin/rclone
'
,
'
sync
'
,
remote
,
contentbase
]
# File formats that "feh" can display directly with no processing
directformats
=
[
...
...
@@ -17,6 +21,9 @@ directformats = [
'
Netpbm image
'
,
]
# Interpreter line for the loop script
loopscript
=
'
#!/bin/bash
\n
'
# Empty the temporary working directory
def
cleantmp
():
try
:
...
...
@@ -28,21 +35,21 @@ def cleantmp():
pass
# Copy a file into the temporary directory
def
tmpcopy
(
filename
):
srcpath
=
os
.
path
.
join
(
contentdir
,
filename
)
def
tmpcopy
(
contentdir
,
filename
):
srcpath
=
os
.
path
.
join
(
contentbase
,
contentdir
,
filename
)
dstpath
=
os
.
path
.
join
(
tmpdir
,
filename
)
subprocess
.
call
([
'
/bin/cp
'
,
'
-p
'
,
'
-f
'
,
srcpath
,
dstpath
])
# Move PNG files from temporary to slide directory
# Returns a list of moved files, and cleans the temporary directory
def
tmpmove
(
moveall
):
def
tmpmove
(
contentdir
,
moveall
):
tmpfiles
=
os
.
listdir
(
tmpdir
)
tmpfiles
.
sort
()
filelist
=
[]
for
f
in
tmpfiles
:
srcpath
=
os
.
path
.
join
(
tmpdir
,
f
)
if
moveall
or
(
f
[
-
4
:]
==
'
.png
'
):
dstpath
=
os
.
path
.
join
(
slidedir
,
f
)
dstpath
=
os
.
path
.
join
(
slide
base
,
content
dir
,
f
)
subprocess
.
call
([
'
/bin/mv
'
,
'
-f
'
,
srcpath
,
dstpath
])
filelist
+=
[
f
]
else
:
...
...
@@ -67,91 +74,135 @@ try:
except
:
filestatus
=
{}
# Get list of content files
files
=
os
.
listdir
(
contentdir
)
files
.
sort
()
# Slide files to preserve
keepcontent
=
{}
keepslides
=
{}
# Examine all content files
for
f
in
files
:
filepath
=
os
.
path
.
join
(
contentdir
,
f
)
sb
=
os
.
stat
(
filepath
)
filetype
=
ms
.
file
(
filepath
)
processfile
=
True
if
f
in
filestatus
:
# Status record exists
# Check size and modification time
thisstatus
=
filestatus
[
f
]
if
(
thisstatus
[
'
s
'
]
==
sb
.
st_size
)
and
(
thisstatus
[
'
m
'
]
==
sb
.
st_mtime
)
and
(
thisstatus
[
'
t
'
]
==
filetype
):
# exact match, do not need to process this file
print
(
'
exact
'
,
f
)
processfile
=
False
# mark resulting slide files to save them
for
i
in
thisstatus
[
'
f
'
]:
keepslides
[
i
]
=
True
else
:
# something has changed
print
(
'
changed
'
,
f
)
thisstatus
[
'
s
'
]
=
sb
.
st_size
thisstatus
[
'
m
'
]
=
sb
.
st_mtime
thisstatus
[
'
t
'
]
=
filetype
else
:
# new file, no status record yet, so make one
print
(
'
new
'
,
f
)
filestatus
[
f
]
=
{}
filestatus
[
f
][
'
s
'
]
=
sb
.
st_size
filestatus
[
f
][
'
m
'
]
=
sb
.
st_mtime
filestatus
[
f
][
'
t
'
]
=
filetype
# Active file, save status record
keepcontent
[
f
]
=
True
# if this content file needs to be made into slide file(s)
if
processfile
:
# Figure out some useful paths
tmppath
=
os
.
path
.
join
(
tmpdir
,
f
)
destpath
=
os
.
path
.
join
(
slidedir
,
f
)
direct
=
False
for
d
in
directformats
:
if
d
in
filetype
:
direct
=
True
if
direct
:
# files that can be displayed directly just need to be copied into place
print
(
'
direct
'
,
filepath
)
tmpcopy
(
f
)
subprocess
.
call
([
'
/bin/cp
'
,
'
-p
'
,
'
-f
'
,
filepath
,
destpath
])
# keepslides[f] = True
elif
'
PDF document
'
in
filetype
:
tmpcopy
(
f
)
subprocess
.
call
([
'
/home/pi/kiosk/bin/file-pdf
'
])
elif
'
PostScript document
'
in
filetype
:
tmpcopy
(
f
)
subprocess
.
call
([
'
/home/pi/kiosk/bin/file-ps
'
])
elif
'
PowerPoint
'
in
filetype
or
'
Microsoft Word
'
in
filetype
or
'
Zip archive data
'
in
filetype
:
tmpcopy
(
f
)
subprocess
.
call
([
'
/home/pi/kiosk/bin/file-office
'
])
elif
'
ASCII text
'
in
filetype
:
tmpcopy
(
f
)
subprocess
.
call
([
'
/home/pi/kiosk/bin/file-text
'
])
else
:
print
(
'
unknown
'
,
filepath
)
print
(
filetype
)
filelist
=
tmpmove
(
direct
)
filestatus
[
f
][
'
f
'
]
=
filelist
for
i
in
filelist
:
keepslides
[
i
]
=
True
def
processdir
(
contentdir
):
slidedir
=
os
.
path
.
join
(
slidebase
,
contentdir
)
contentpath
=
os
.
path
.
join
(
contentbase
,
contentdir
)
# Make the slide directory, in case it is new
try
:
os
.
mkdir
(
slidedir
)
except
:
pass
# Get list of content files
files
=
os
.
listdir
(
os
.
path
.
join
(
contentbase
,
contentdir
))
files
.
sort
()
# Examine all content files
for
f
in
files
:
filepath
=
os
.
path
.
join
(
contentpath
,
f
)
sb
=
os
.
stat
(
filepath
)
filetype
=
ms
.
file
(
filepath
)
processfile
=
True
filetag
=
os
.
path
.
join
(
contentdir
,
f
)
if
filetag
in
filestatus
:
# Status record exists
# Check size and modification time
thisstatus
=
filestatus
[
filetag
]
if
(
thisstatus
[
'
s
'
]
==
sb
.
st_size
)
and
(
thisstatus
[
'
m
'
]
==
sb
.
st_mtime
)
and
(
thisstatus
[
'
t
'
]
==
filetype
):
# exact match, do not need to process this file
print
(
'
exact
'
,
f
)
processfile
=
False
# mark resulting slide files to save them
for
i
in
thisstatus
[
'
f
'
]:
keepslides
[
os
.
path
.
join
(
contentdir
,
i
)]
=
True
else
:
# something has changed
print
(
'
changed
'
,
f
)
thisstatus
[
'
s
'
]
=
sb
.
st_size
thisstatus
[
'
m
'
]
=
sb
.
st_mtime
thisstatus
[
'
t
'
]
=
filetype
else
:
# new file, no status record yet, so make one
print
(
'
new
'
,
f
)
filestatus
[
filetag
]
=
{}
filestatus
[
filetag
][
'
s
'
]
=
sb
.
st_size
filestatus
[
filetag
][
'
m
'
]
=
sb
.
st_mtime
filestatus
[
filetag
][
'
t
'
]
=
filetype
# Active file, save status record
keepcontent
[
filetag
]
=
True
# if this content file needs to be made into slide file(s)
if
processfile
:
# Figure out some useful paths
tmppath
=
os
.
path
.
join
(
tmpdir
,
f
)
destpath
=
os
.
path
.
join
(
slidedir
,
f
)
direct
=
False
for
d
in
directformats
:
if
d
in
filetype
:
direct
=
True
if
direct
:
# files that can be displayed directly just need to be copied into place
print
(
'
direct
'
,
filepath
)
tmpcopy
(
contentdir
,
f
)
subprocess
.
call
([
'
/bin/cp
'
,
'
-p
'
,
'
-f
'
,
filepath
,
destpath
])
keepslides
[
filetag
]
=
True
elif
'
PDF document
'
in
filetype
:
tmpcopy
(
contentdir
,
f
)
subprocess
.
call
([
'
/home/pi/kiosk/bin/file-pdf
'
])
elif
'
PostScript document
'
in
filetype
:
tmpcopy
(
contentdir
,
f
)
subprocess
.
call
([
'
/home/pi/kiosk/bin/file-ps
'
])
elif
'
PowerPoint
'
in
filetype
or
'
Microsoft Word
'
in
filetype
or
'
Zip archive data
'
in
filetype
:
tmpcopy
(
contentdir
,
f
)
subprocess
.
call
([
'
/home/pi/kiosk/bin/file-office
'
])
elif
'
ASCII text
'
in
filetype
:
tmpcopy
(
contentdir
,
f
)
subprocess
.
call
([
'
/home/pi/kiosk/bin/file-text
'
])
else
:
print
(
'
unknown
'
,
filepath
)
print
(
filetype
)
filelist
=
tmpmove
(
contentdir
,
direct
)
filestatus
[
filetag
][
'
f
'
]
=
filelist
for
i
in
filelist
:
keepslides
[
os
.
path
.
join
(
contentdir
,
i
)]
=
True
contentdirs
=
[
'
.
'
]
# Turn the configuration file from a Google Sheet to a CSV file
subprocess
.
call
([
'
/home/pi/kiosk/bin/process-conf
'
])
# Run through the configuration file
confdata
=
open
(
confcsv
).
readlines
()
for
confline
in
confdata
[
1
:]:
# Ignore comments
if
confline
[
0
]
!=
'
#
'
:
fields
=
confline
.
split
(
'
,
'
)
action
=
fields
[
0
].
strip
().
lower
()
parameter
=
fields
[
1
].
strip
()
pathname
=
fields
[
2
].
strip
()
if
action
==
'
slides
'
:
loopscript
+=
"
cd
'
%s
'
\n
"
%
pathname
loopscript
+=
"
feh --cycle-once -FZ -D %s -R %s
\n
"
%
(
parameter
,
parameter
)
loopscript
+=
"
cd ..
\n
"
contentdirs
+=
[
pathname
]
processdir
(
pathname
)
if
action
==
'
video
'
:
loopscript
+=
"
omxplayer -b
'
../content/%s
'
\n
"
%
pathname
loopout
=
open
(
looptmp
,
'
w
'
)
loopout
.
write
(
loopscript
)
loopout
.
close
()
subprocess
.
call
([
'
/bin/chmod
'
,
'
u+x
'
,
looptmp
])
subprocess
.
call
([
'
/bin/mv
'
,
'
-f
'
,
looptmp
,
loopfile
])
print
(
'
keepslides
'
,
keepslides
)
# final cleanup, delete obsolete slides
# Get list of slide files
files
=
os
.
listdir
(
slidedir
)
files
.
sort
()
for
f
in
files
:
if
f
not
in
keepslides
:
os
.
unlink
(
os
.
path
.
join
(
slidedir
,
f
))
print
(
'
unlink slide
'
,
f
)
for
d
in
contentdirs
:
slidedir
=
os
.
path
.
join
(
slidebase
,
d
)
files
=
os
.
listdir
(
slidedir
)
files
.
sort
()
for
f
in
files
:
if
os
.
path
.
join
(
d
,
f
)
not
in
keepslides
:
try
:
os
.
unlink
(
os
.
path
.
join
(
slidedir
,
f
))
print
(
'
unlink slide
'
,
f
)
except
:
pass
# Delete status records for obsolete content
deletekeys
=
[]
...
...
This diff is collapsed.
Click to expand it.
bin/show
+
6
−
2
View file @
2d39a895
#!/bin/sh
export
DISPLAY
=
:0
/home/pi/kiosk/bin/do-runner
>
/home/pi/kiosk/log 2>&1 &
cd
/home/pi/kiosk/slides
feh
-FZ
-D
10
-R
10
cd
/home/pi/kiosk/content
feh
-FZ
background.png &
while
true
do
/home/pi/kiosk/loop
done
This diff is collapsed.
Click to expand it.
config-syntax
deleted
100644 → 0
+
0
−
16
View file @
44991f49
Configuration file syntax
name it "conf" ?
command parameters
s: show slides
s seconds-per-slide optional-subfolder
v video filename
Notes:
need to be sure system ignores unrecognized file types
This diff is collapsed.
Click to expand it.
loop
0 → 100755
+
8
−
0
View file @
2d39a895
#!/bin/bash
cd
'Slideshow'
feh
--cycle-once
-FZ
-D
3
-R
3
cd
..
omxplayer
-b
'../content/weather.mp4'
cd
'MoreSlides'
feh
--cycle-once
-FZ
-D
8
-R
8
cd
..
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment