Skip to content

Commit

Permalink
Add a hooks.d directory for arbitrary scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
colinleroy committed Dec 16, 2018
1 parent fcf827c commit 380e7b6
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
raspi-rotate.tar.gz
12 changes: 12 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,10 +1,22 @@
bindir=/usr/local/bin
etcdir=/etc/raspi-rotate
tmpldir=$(etcdir)/xorg.conf.d
hooksdir=$(etcdir)/hooks.d

install:
mkdir -p $(bindir)
mkdir -p $(etcdir)
mkdir -p $(tmpldir)
mkdir -p $(hooksdir)
install -m 0755 bin/raspi-rotate-screen $(bindir)
install -m 0644 etc/xorg.conf.d/99-raspi-rotate.conf.tmpl $(tmpldir)
install -m 0755 etc/hooks.d/*.sh $(hooksdir)

dist:
tar -zcf raspi-rotate.tar.gz \
../raspi-rotate/bin \
../raspi-rotate/etc \
../raspi-rotate/COPYING \
../raspi-rotate/AUTHORS \
../raspi-rotate/Makefile \
../raspi-rotate/README.md
9 changes: 9 additions & 0 deletions bin/raspi-rotate-screen
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

#Variables
CONF_DIR="/etc/raspi-rotate"
HOOKS_DIR="$CONF_DIR/hooks.d"
XORG_TEMPLATE="$CONF_DIR/xorg.conf.d/99-raspi-rotate.conf.tmpl"
XORG_CONF_DIR="/etc/X11/xorg.conf.d"
XORG_CONF_FILE="$XORG_CONF_DIR/99-raspi-rotate.conf"
Expand Down Expand Up @@ -60,5 +61,13 @@ mkdir -p "$XORG_CONF_DIR"
chmod 644 "$TMP_FILE"
mv "$TMP_FILE" "$XORG_CONF_FILE"

#Run hooks
if [ -d "$HOOKS_DIR" ] ; then
for f in $HOOKS_DIR/?*.sh ; do
[ -x "$f" ] && . "$f"
done
unset f
fi

echo "Rotation set to $ROTATE"

9 changes: 9 additions & 0 deletions etc/hooks.d/01-bootsplash.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash

if [ "$ROTATE" != "" ]; then
if [ -d "/usr/share/bootsplash-$ROTATE" ]; then
echo "Linking /usr/share/bootsplash-$ROTATE to /usr/share/bootsplash"
rm -f /usr/share/bootsplash
ln -s "/usr/share/bootsplash-$ROTATE" /usr/share/bootsplash
fi
fi

0 comments on commit 380e7b6

Please sign in to comment.