diff --git a/CHANGELOG.md b/CHANGELOG.md index 3f40dec2..25447243 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ This project adheres to [Semantic Versioning](http://semver.org/). - Finnish translation. - Method to overwrite the module's header. [See documentation.](https://github.com/MichMich/MagicMirror/tree/develop/modules#getheader) - Option to limit access to certain IP addresses based on the value of `ipWhitelist` in the `config.js`, default is access from localhost only (Issue [#456](https://github.com/MichMich/MagicMirror/issues/456)) +- Add Splash screen on boot. ### Updated - Modified translations for Frysk. diff --git a/installers/raspberry.sh b/installers/raspberry.sh index ce37e86f..4c42dcde 100644 --- a/installers/raspberry.sh +++ b/installers/raspberry.sh @@ -113,6 +113,34 @@ else exit; fi +# Check if plymouth is installed (default with PIXEL desktop environment), then install custom splashscreen. +echo -e "\e[96mCheck plymouth installation ...\e[0m" +if command_exists plymouth; then + THEME_DIR="/usr/share/plymouth/themes" + echo -e "\e[90mSplashscreen: Checking themes directory.\e[0m" + if [ -d $THEME_DIR ]; then + echo -e "\e[90mSplashscreen: Create theme directory if not exists.\e[0m" + if [ ! -d $THEME_DIR/MagicMirror ]; then + sudo mkdir $THEME_DIR/MagicMirror + fi + + if sudo cp ~/MagicMirror/splashscreen/splash.png $THEME_DIR/MagicMirror/splash.png && sudo cp ~/MagicMirror/splashscreen/MagicMirror.plymouth $THEME_DIR/MagicMirror/MagicMirror.plymouth && sudo cp ~/MagicMirror/splashscreen/MagicMirror.script $THEME_DIR/MagicMirror/MagicMirror.script; then + echo -e "\e[90mSplashscreen: Theme copied successfully.\e[0m" + if sudo plymouth-set-default-theme -R MagicMirror; then + echo -e "\e[92mSplashscreen: Changed theme to MagicMirror successfully.\e[0m" + else + echo -e "\e[91mSplashscreen: Couldn't change theme to MagicMirror!\e[0m" + fi + else + echo -e "\e[91mSplashscreen: Copying theme failed!\e[0m" + fi + else + echo -e "\e[91mSplashscreen: Themes folder doesn't exist!\e[0m" + fi +else + echo -e "\e[93mplymouth is not installed.\e[0m"; +fi + echo " " echo -e "\e[92mWe're ready! Run \e[1m\e[97mDISPLAY=:0 npm start\e[0m\e[92m from the ~/MagicMirror directory to start your MagicMirror.\e[0m" echo " " diff --git a/splashscreen/MagicMirror.plymouth b/splashscreen/MagicMirror.plymouth new file mode 100644 index 00000000..b6887bf5 --- /dev/null +++ b/splashscreen/MagicMirror.plymouth @@ -0,0 +1,8 @@ +[Plymouth Theme] +Name=MagicMirror +Description=Mirror Splash +ModuleName=script + +[script] +ImageDir=/usr/share/plymouth/themes/MagicMirror +ScriptFile=/usr/share/plymouth/themes/MagicMirror/MagicMirror.script diff --git a/splashscreen/MagicMirror.script b/splashscreen/MagicMirror.script new file mode 100644 index 00000000..d7e7b860 --- /dev/null +++ b/splashscreen/MagicMirror.script @@ -0,0 +1,50 @@ +screen_width = Window.GetWidth(); +screen_height = Window.GetHeight(); + +theme_image = Image("splash.png"); +image_width = theme_image.GetWidth(); +image_height = theme_image.GetHeight(); + +scale_x = image_width / screen_width; +scale_y = image_height / screen_height; + +flag = 1; + +if (scale_x > 1 || scale_y > 1) +{ + if (scale_x > scale_y) + { + resized_image = theme_image.Scale (screen_width, image_height / scale_x); + image_x = 0; + image_y = (screen_height - ((image_height * screen_width) / image_width)) / 2; + } + else + { + resized_image = theme_image.Scale (image_width / scale_y, screen_height); + image_x = (screen_width - ((image_width * screen_height) / image_height)) / 2; + image_y = 0; + } +} +else +{ + resized_image = theme_image.Scale (image_width, image_height); + image_x = (screen_width - image_width) / 2; + image_y = (screen_height - image_height) / 2; +} + +if (Plymouth.GetMode() != "shutdown") +{ + sprite = Sprite (resized_image); + sprite.SetPosition (image_x, image_y, -100); +} + +message_sprite = Sprite(); +message_sprite.SetPosition(screen_width * 0.1, screen_height * 0.9, 10000); + +fun message_callback (text) { + my_image = Image.Text(text, 1, 1, 1); + message_sprite.SetImage(my_image); + sprite.SetImage (resized_image); +} + +Plymouth.SetUpdateStatusFunction(message_callback); diff --git a/splashscreen/splash.png b/splashscreen/splash.png new file mode 100644 index 00000000..f76b0cff Binary files /dev/null and b/splashscreen/splash.png differ