Skip to content

Latest commit

 

History

6 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 

Repository files navigation

MMM-CarouselCompliments

A MagicMirror² module that displays a random string — a standalone fork of the core compliments module, built specifically to be safe when nested inside MMM-Carousel or any other module that manages visibility via module.hide() / module.show().

Origin

This module is derived from MagicMirror²'s built-in compliments module (source), based on:

See LICENSE for the full license text, which carries forward the original MIT notice as required.

Why a separate module instead of a patch to core compliments?

Core compliments never implements suspend()/resume(), so its internal update timer keeps running, which keeps triggering its own fade animation even while another module (like MMM-Carousel) has it hidden via a locked module.hide(). When two independent, uncoordinated animation timers touch the same module, they can visually collide. Since compliments ships as part of MagicMirror core, patching it directly means the fix disappears on the next MagicMirror update. A standalone module avoids both problems.

Differences from core compliments

Change Why
Renamed to MMM-CarouselCompliments Avoids overwriting/conflicting with core compliments
Added suspend() / resume() Pauses the update timer while hidden (e.g. by MMM-Carousel), so it never fires an update behind another module's back
Guarded remoteFile loading A failed or slow fetch no longer overwrites compliments with null; falls back to whatever was already loaded
Backtick (`text`) segments render as monospace Lets a remoteFile entry mark part of a line as code-styled, without allowing arbitrary HTML/script injection from remote content

Everything else — cron-based and date-based special-day compliments, weather-based compliments via CURRENTWEATHER_TYPE, remoteFile support, sequential vs. random selection — is unchanged from core.

Screenshot

(add one here once you have it — a compliment rendered on your mirror is enough)

Installation

cd ~/MagicMirror/modules
git clone https://github.com/MetroCS/MMM-CarouselCompliments.git

No npm install is required; this module has no additional dependencies beyond what MagicMirror already loads (moment.js, croner.js).

Using the module

Add it to the modules array in config/config.js:

{
    module: "MMM-CarouselCompliments",
    position: "bottom_center",
    config: {
        // see below
    }
}

To use it as a member of an MMM-Carousel slide, reference it by module name in your slides config exactly as you would any other module. No special configuration is needed on the Carousel side; the suspend()/resume() support handles the rest.

Configuration options

Option Default Description
compliments see below Object of compliment arrays, keyed by time-of-day (anytime, morning, afternoon, evening), weather type, or a special-day pattern. Ignored if remoteFile is set and loads successfully.
remoteFile null URL (or local path, relative to the module folder) to a JSON file with the same shape as compliments, fetched at startup.
remoteFileRefreshInterval 0 Milliseconds between re-fetching remoteFile. 0 disables periodic refresh. If set, must be at least 15 minutes (900000 ms) unless running in test mode.
updateInterval 30000 Milliseconds between showing a new compliment.
fadeSpeed 4000 Milliseconds for the fade transition between compliments.
morningStartTime / morningEndTime 3 / 12 Hour range (24h) treated as "morning".
afternoonStartTime / afternoonEndTime 12 / 17 Hour range (24h) treated as "afternoon". Anything outside the morning/afternoon ranges is treated as "evening".
random true Pick compliments randomly (never repeating the immediately previous one) instead of sequentially.
specialDayUnique false If true, a matching special-day compliment (date-based or cron-based key in compliments) replaces the normal pool instead of being added to it.
classes "thin xlarge bright pre-line" CSS classes applied to the compliment text wrapper. Uses MagicMirror's built-in size classes (xsmall/small/medium/large/xlarge) — see note below if adjusting text size via custom.css instead.

Default compliments object

compliments: {
    anytime: ["Hey there sexy!"],
    morning: ["Good morning, handsome!", "Enjoy your day!", "How was your sleep?"],
    afternoon: ["Hello, beauty!", "You look sexy!", "Looking good today!"],
    evening: ["Wow, you look hot!", "You look nice!", "Hi, sexy!"],
    "....-01-01": ["Happy new year!"]
}

Keys can be:

  • One of anytime, morning, afternoon, evening
  • A weather type matching what your weather module currently broadcasts (e.g. rain, snow, day_sunny)
  • A date pattern (MM-DD, wildcards allowed with ., e.g. "....-01-01" for New Year's Day) or a five-field cron expression, for special-day compliments

Monospace text

Wrap any part of a compliment line in backticks to render it as monospace, e.g.:

"anytime": [
    "There's no place like `127.0.0.1`",
    "My code doesn't have any bugs,\nit just develops `random spontaneous features`."
]

This is handled by wrapping the segment in a <code> element. It does not parse HTML, so remote JSON content can't inject arbitrary markup.

Browsers apply a default monospace font to <code> automatically, so this works with no CSS changes. To customize its appearance further (background tint, padding, letter-spacing, etc.), target it in custom.css:

.MMM-CarouselCompliments code {
    font-family: monospace;
    background: rgba(255, 255, 255, 0.08);
    padding: 0 4px;
    border-radius: 3px;
}

Adjusting text size

The compliment text's size comes from the classes option (default includes MagicMirror's built-in .xlarge class), applied directly to the element containing the text — not from the module's outer wrapper. To resize:

  • Simplest: change classes to use a different built-in size (xsmall, small, medium, large, xlarge)
  • Custom size: target the class combination directly in custom.css, e.g.:
    .MMM-CarouselCompliments .xlarge {
        font-size: 2.2em;
    }
    A rule on .MMM-CarouselCompliments alone (the outer wrapper) won't work, since the inner element's own .xlarge class overrides inherited font-size.

License

MIT, inherited from MagicMirror²'s core compliments module. See LICENSE.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages