Skip to content

About

A module for the MagicMirror 2 that adds touch buttons for showing/hiding other modules.

Resources

Code of conduct

Stars

19 stars

Watchers

4 watching

Forks

Repository files navigation

MMM-Modulebar

This is an extension for MagicMirror².

This module adds a touch menu to hide or show the modules defined in config.js.

The all button covers the screen with a black overlay and leaves its restore button accessible. Press it again to restore the previous view, including the visibility of any swapped modules. Legacy display: none rules for .paint-it-black in custom.css are supported.

Screenshots

Module with symbols only in row mode:

Modulebar Row Symbols

Module with symbols only in column mode:

Modulebar Column Symbols

Module with symbols and text in column mode:

Modulebar Column Symbols Text

Module with symbols and text in row mode:

Modulebar Row Symbols Text

This is my own mirrors view (Bottom Bar) using some addition in the custom.css see below

Modulebar Custom CSS

Installation

In your terminal, go to your MagicMirror² modules folder:

cd ~/MagicMirror/modules

Clone this repository:

git clone https://github.com/Snille/MMM-Modulebar.git
cd MMM-Modulebar

Update

To update the module:

cd ~/MagicMirror/modules/MMM-Modulebar
git pull
npm ci --omit=dev

Using The Module

To use this module, add it to config/config.js:

{
	module: "MMM-Modulebar",
	position: "bottom_bar", // This can be any of the regions.
	header: "Modules", // Optional
	classes: "default everyone", // Optional
	config: {
		// See 'Configuration options' for more information.
	}
},

Configuration Options

The following properties can be configured:

Option Default Description
allowForce false Allow the module to force modules to be shown (if hidden and locked by ex. profile-switcher).

Possible values: true or false
forceSwap [] Module names that replace each other when shown using this bar. Showing one member hides visible members with a different name. Buttons outside this list work independently. See Swapping Modules.
showBorder true Determines if the border around the buttons should be shown.

Possible values: true or false
minWidth 0px The minimum width for all the buttons.

Possible values: css length
minHeight 0px The minimum height for all the buttons.

Possible values: css length
picturePlacement left The location of the symbol or image relative to the text.

Possible values: left, right, top or bottom
direction row The direction of the menu.

Possible values: row, column, row-reverse or column-reverse
animationSpeed 1000 The speed of the hide and show animation (lower is faster) Possible values: 0-10000.
zindex 1000 Z-Index value for the hide all plane (this is preferably a high value for the black plane to show above everything else. Possible values: 0-10000.
visability 0.4 Visibility of the "unhide all button" (if defined) when all is hidden Possible values: 0.0 - 1.0.
buttons Clock example button All the different buttons in the menu.

Possible values: a button configuration, see Configuring Buttons

Configuring Buttons

Buttons have to be placed in buttons in the config. A button contains a unique number as a key and a set of options in the object ({}).

Each button starts with it's own unique number (ex. "1"), then add the options needed.

Option Description
module A module name. Note: if set to all , all of the modules will be hidden or shown.
Possible values: all,clock,currentweather,MMM-xxx
text A string to display in the button.

Note: if no value is set no text will be displayed.
Possible values: string
text2 A string to display in the button when module is hidden.

Note: if no value is set no text will be displayed.
Possible values: string
symbol A symbol to display in the button.

Note: if no value is set no symbol will be displayed.
Possible values: See Font Awesome website
symbol2 A secondary symbol to display in the button when module is hidden.

Note: if no value is set no symbol will be displayed.
Possible values: See Font Awesome website
img An image to display in the button.

Note: it will only be displayed if no symbol is set.
Possible values: A path to an image (an url or local path)
img2 A secondary image to display in the button when module is hidden.

Note: it will only be displayed if no symbol is set.
Possible values: A path to an image (an url or local path)
size The size of the symbol.

Note: will only have effect on a symbol.
Default value: 1
Possible values: 1, 2, 3, 4 or 5
width The width of the image.

Note: will only have effect on an image.
Possible values: number
height The height of the image.

Note: will only have effect on an image.
Possible values: number
idnum The unique module number if you have more then one of the same module (and want to manipulate only one of the modules), you can find the module numbers if you inspect the code and then check the "console" (in a normal web browser) when showing and hiding the module(s) (without setting this number) with the button.

Possible values: number

Or if you use multiple instances of the same module many times and you don't want to hide all or just one with one button, you can specify the numbers of the modules (of the same type) you want to hide in an array.

Number Array [3,6,2,7]
showUrl If you have something you want to "do" via visiting a link before showing the module, this is where to put the link, it will be visited (ignoring the result) before showing the module..

Possible values: url
hideUrl If you have something you want to "do" via visiting a link after hiding the module, this is where to put the link, it will be visited (ignoring the result) after hiding the module..

Possible values: url
gotoUrl Use this if want to navigate away to another page. The special value "back" will reload a previous page. This option should be used with a browser and want to exit MM.

Possible values: url or back

An example:

  buttons: {
    // A number (unique for each button) lowest number will be displayed first...
    "1": {
      // This button hides everything and uses two symbols.
      module: "all",
      symbol: "toggle-on",
      symbol2: "toggle-off",
    },
    "2": {
      // This is a button with text that changes and a symbol that changes.
      // The EXACT module name (case sensitive)
      module: "currentweather",
      text: "Current Weather on",
      text2: "Current Weather off",
      symbol: "fas fa-sun",
      symbol2: "far fa-sun",
    },
    "4": {
      // A button with only a symbol and an idnum to target a specific weatherforecast module.
      module: "weatherforecast",
      symbol: "sun-o",
      // The ID-number of the "weatherforecast" module (when you have more then one).
      idnum: 8,
    },
    "6": {
      // A button with only a symbol and an idnum to target another specific weatherforecast module.
      module: "weatherforecast",
      symbol: "star-o",
      // The ID-number of the other "weatherforecast" module (when you have more then one).
      idnum: 6,
    },
    "8": {
      // A button with text and a changing symbol.
      module: "clock",
      text: "Clock",
      symbol: "bell",
      symbol2: "bell-slash",
    },
    "10": {
      // A button to show and hide for example a [MMM-MotionEye](https://github.com/CatoAntonsen/MMM-MotionEye) module.
      module: "MMM-MotionEye",
      idnum: 7,
      text: "CAM1",
      showUrl: "http://MagicMirrorIP:8080/motioneye/1",
      hideUrl: "http://MagicMirrorIP:8080/motioneye/hide/1"
    },
  }

Swapping Modules

Set forceSwap to an array of exact, case-sensitive module names. When a button shows a hidden member, the bar hides the other named modules. Clicking a visible member still hides it normally. The default empty array keeps independent toggles.

For example, place a calendar and news feed in the same region and switch between them:

{
  module: "MMM-Modulebar",
  position: "bottom_bar",
  config: {
    forceSwap: ["calendar", "newsfeed"],
    buttons: {
      "1": { module: "calendar", text: "Calendar", text2: "Show calendar" },
      "2": { module: "newsfeed", text: "News", text2: "Show news" },
      "3": { module: "clock", text: "Clock" }
    }
  }
}

The clock button does not affect the swap group. Multiple instances of the selected module name are kept together; idnum still limits which instances its button toggles. The bar updates its buttons' labels, symbols and images after a swap. Automatic peer hiding only changes visibility; showUrl and hideUrl run for the button clicked, as usual.

Swapping happens on a button click, so it does not hide modules at startup or enforce exclusivity when another module changes visibility. Existing visibility locks are respected unless allowForce is enabled. If the selected module cannot be shown because it is locked, the currently visible group members remain visible.

Development

Use Node.js 20.19+, 22.13+, or 24+ for the development tools. Install development dependencies and run all checks with:

npm ci
npm run check

The tests use Node's built-in test runner and exercise button clicks, swap groups, instance selection and visibility locks.

Version 1.1.1 has been tested on MagicMirror 2.39.0-develop with Node.js 22.23.3, including the all button and swaps between modules.

Custom CSS

Here is my CSS settings for the module that I have added to my custom.css to give it the extra special look. :)

/* MMM-Modulebar ------------------------------------*/
.modulebar-button {
  margin: 1px;
  padding: 1px 1px;
  border: 2px solid #fff; 
  background-color: #fff;
  color: #000;
  border-radius: 0px;
  border-radius: 50%;
  width: 60px;
  height: 60px;
}
.modulebar-picture {
  margin: 0px 0px;
  border-radius: 50%;
}
.modulebar-menu {
  align-items: flex-start;
}
/*****************************************************/

Notes

  • Important: unfortunately positioning this module as full screen will result in the menu floating top left. I currently do not know how to fix this but will look into it. If you know how don't hesitate to either write me or send me a pull request!
  • If the image is an local path and it does not show. Try different ways to write the local path. If this still does not work then try putting the image in a folder in your MagicMirror folder and use as local path folder name/image name.
  • If only height or width is set for an image the other size will scale to maintain it the image it's original aspect ratio.
  • Module name is case sensitive.
  • If both the text and symbol aren't set for a button then the button won't contain anything, but still show the border.
  • The symbols are all from the Font Awesome website.
  • The text may contain HTML tags and will be displayed as HTML.

About

A module for the MagicMirror 2 that adds touch buttons for showing/hiding other modules.

Resources

Code of conduct

Stars

19 stars

Watchers

4 watching

Forks

Releases

Packages

Used by

Contributors

Languages