Download the PHP package brocode/module-screen-awake without Composer
On this page you can find all versions of the php package brocode/module-screen-awake. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download brocode/module-screen-awake
More information about brocode/module-screen-awake
Files in brocode/module-screen-awake
Package module-screen-awake
Short Description A "Keep screen on" button for Magento 2 product and CMS pages: keeps the customer's phone screen awake while they follow assembly, care or installation instructions, using the browser's Screen Wake Lock API.
License MIT
Homepage https://github.com/brosenberger/module-screen-awake
Informations about the package module-screen-awake
BroCode_ScreenAwake
A "Keep screen on" button for Magento 2 product and CMS pages. It keeps the customer's phone screen awake while they follow the page: assembly steps, care routines, fitting guides, a recipe on a kitchenware product. It uses the browser's Screen Wake Lock API. The customer taps the button once and the screen stays on until they tap it again or leave the page.
Module page: brocode.at/modules/module-screen-awake/
In production mode, also run setup:di:compile and setup:static-content:deploy as
usual.
What it does
- One button, no new content. The page stays exactly as it is. The button is the only thing the module adds.
- Only where it makes sense. On product pages the button renders only for products whose attribute Show 'Keep Screen On' Button (group Content, store-view scope) is set to Yes. A product without instructions doesn't get a button.
- CMS pages via widget. Insert the widget Keep Screen On Button into any CMS page or block, such as a guide page.
- One switch per store view. Stores > Configuration > Catalog > Catalog > Keep Screen On Button > Enabled turns the button off everywhere, product pages and widgets alike. Default: on.
- Survives tab switches. The browser drops the lock whenever the page is hidden, for example when the customer switches to the timer app. The button requests it again when the page becomes visible. Without that, the screen goes dark two minutes after the first switch.
- Invisible where unsupported. The button starts
hiddenand only appears whennavigator.wakeLockexists: Chrome and Edge 84+, Safari 16.4+ (iOS included), and Firefox 126+. - CSP-safe. No inline script; the component loads through
data-mage-init.
Hooks for the theme and analytics
The module ships no styling beyond Luma's action secondary button classes. Two hooks
let a theme or tag manager do more:
| Hook | Use |
|---|---|
body.is-screen-awake |
Present while the customer wants the screen on. Style larger type or hide sticky banners in your own theme CSS. |
screenawake:change event on document |
event.detail.on is true / false. Push it to the dataLayer to measure usage. |
Requirements and limits
- Magento 2.4.x, PHP 8.1–8.4. Verified on 2.4.8-p5 with Luma.
brocode/module-entityservicescreates the product attribute; Composer installs it automatically.- Luma-based themes. Hyvä doesn't load RequireJS components, so a Hyvä store needs
a small compatibility template (an Alpine
x-datawrapper around the same logic). That template isn't included. - The site must be served over HTTPS; the API only exists in secure contexts.
- A
Permissions-Policyheader containingscreen-wake-lock=()blocks the lock entirely. Check your server headers if the button toggles but the screen still dims. - Headless browsers refuse the lock (
NotAllowedError). Test in a real browser.
Uninstall
module:uninstall reverts the data patch and removes the screen_awake_button
attribute. When removing the package by hand instead, delete the attribute yourself.
License
MIT, see LICENSE.
If this saves you time: buy me a coffee.
All versions of module-screen-awake with dependencies
brocode/module-entityservices Version ^1.6
magento/framework Version >=103.0.0
magento/module-catalog Version >=104.0.0
magento/module-eav Version >=102.0.0
magento/module-store Version >=101.0.0
magento/module-widget Version >=101.0.0