Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Merged by Bors] - Automate reloading display configuration #122

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions scripts/bin/initialise-display-config
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/sh
set -eu

wait_for()
{
until
until
inotifywait --event create "$(dirname "$1")"&
inotify_pid=$!
[ -e "$1" ] || sleep 2 && [ -e "$1" ]
do
wait "${inotify_pid}"
done
kill "${inotify_pid}"
[ -O "$1" ]
do
sleep 1
done
}

display_file="$SNAP_DATA/frame.display"

wait_for "${display_file}"

if [ -z "$(snapctl get display)" ] && ! grep "DO NOT EDIT THIS FILE BY HAND" "${display_file}"
then
snapctl set display="$(cat "${display_file}")"
fi
6 changes: 6 additions & 0 deletions scripts/bin/run-daemon
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
#!/bin/sh
set -eux

display_file="$SNAP_DATA/frame.display"
if [ -z "$(snapctl get display)" ] && ! [ -e "${display_file}" ]
then
initialise-display-config&
Saviq marked this conversation as resolved.
Show resolved Hide resolved
fi

exec nohup "$@"
7 changes: 4 additions & 3 deletions snap/hooks/configure
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,13 @@ EOT
mv "${display_file}" "${display_file}.save" || true
mv "${display_temp}" "${display_file}"
chmod a+r "${display_file}"
let config_changes+=1
! [ -e "${SNAP}/miral-lt-3.8" ] || ((config_changes+=1))
else
rm "${display_temp}"
fi
else
elif grep "DO NOT EDIT THIS FILE BY HAND" "${display_file}" &> /dev/null; then
mv "${display_file}" "${display_file}.save" || true
((config_changes+=1))
fi

# config_file
Expand Down Expand Up @@ -86,7 +87,7 @@ if ! diff "${config_temp}" "${config_file}" > /dev/null; then
mv "${config_file}" "${config_file}.save" || true
mv "${config_temp}" "${config_file}"
chmod a+r "${config_file}"
let config_changes+=1
((config_changes+=1))
else
rm "${config_temp}"
fi
Expand Down
11 changes: 11 additions & 0 deletions snap/snapcraft.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,8 @@ parts:
scripts:
plugin: dump
source: scripts
stage-packages:
- inotify-tools

anon-shm-preload:
source: https://github.com/MirServer/anon-shm-preload.git
Expand All @@ -168,3 +170,12 @@ parts:
find . -type f,l -exec rm -f $SNAPCRAFT_PRIME/usr/lib/${SNAPCRAFT_ARCH_TRIPLET}/{} \;
rm -fr "$SNAPCRAFT_PRIME/usr/lib/${SNAPCRAFT_ARCH_TRIPLET}/dri"
rm -fr "$SNAPCRAFT_PRIME/usr/share/"{bug,doc,doc-base,drirc.d,glvnd,libdrm,lintian,man}
# Back compatibility fix until MirAL 3.8 is released
miral_version=`LANG=C apt-cache policy libmiral-dev | sed -rne 's/^\s+Candidate:\s+([0-9]*\.[0-9])\..+$/\1/p'`
if [ ${miral_version%.*} -eq 3 ] && [ ${miral_version#*.} -lt 8 ]
then
touch $SNAPCRAFT_PRIME/miral-lt-3.8
else
rm -f $SNAPCRAFT_PRIME/miral-lt-3.8
fi