Skip to content

Commit

Permalink
Add frontend, fix apply.sh
Browse files Browse the repository at this point in the history
  • Loading branch information
Informatic committed Jan 5, 2022
1 parent 1c13365 commit 31b95ab
Show file tree
Hide file tree
Showing 16 changed files with 8,777 additions and 11 deletions.
72 changes: 72 additions & 0 deletions .enyoconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
{
"title": "",
"libDir": "lib",
"paths": [],
"libraries": [
"enyo",
"moonstone",
"spotlight",
"layout",
"svg",
"enyo-ilib",
"enyo-webos"
],
"sources": {
"enyo": "https://github.com/enyojs/enyo.git",
"moonstone": "https://github.com/enyojs/moonstone.git",
"spotlight": "https://github.com/enyojs/spotlight.git",
"layout": "https://github.com/enyojs/layout.git",
"svg": "https://github.com/enyojs/svg.git",
"enyo-ilib": "https://github.com/enyojs/enyo-ilib.git",
"enyo-webos": "https://github.com/enyojs/enyo-webos.git"
},
"targets": {
"enyo": "2.7.0",
"moonstone": "2.7.0",
"spotlight": "2.7.0",
"layout": "2.7.0",
"svg": "2.7.0",
"enyo-ilib": "2.7.0",
"enyo-webos": "2.7.0"
},
"production": false,
"devMode": true,
"cache": true,
"resetCache": false,
"trustCache": false,
"cacheFile": ".enyocache",
"clean": false,
"sourceMaps": true,
"externals": true,
"strict": false,
"skip": [],
"library": false,
"wip": false,
"outDir": "dist",
"outFile": "index.html",
"lessPlugins": [
{
"name": "resolution-independence",
"options": {
"baseSize": 24
}
}
],
"assetRoots": [],
"lessOnlyLess": false,
"minifyCss": false,
"inlineCss": true,
"outCssFile": "output.css",
"outJsFile": "output.js",
"inlineJs": true,
"templateIndex": "",
"watch": false,
"watchPaths": [],
"polling": false,
"pollingInterval": 100,
"headScripts": [],
"tailScripts": [],
"promisePolyfill": false,
"styleOnly": false,
"lessVars": []
}
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node_modules
.enyocache
dist
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "lib/enyo"]
path = lib/enyo
url = https://github.com/enyojs/enyo.git
12 changes: 12 additions & 0 deletions appinfo.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"id": "org.webosbrew.custom-screensaver",
"version": "1.0.0",
"vendor": "webosbrew.org",
"title": "Custom Screensaver",
"icon": "assets/icon80.png",
"largeIcon": "assets/icon130.png",
"main": "index.html",
"iconColor": "#ffffff",
"type": "web",
"appDescription": "The last custom webOS Screensaver you will ever need"
}
4 changes: 2 additions & 2 deletions assets/apply.sh
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#!/bin/sh

set -ex
set -e -o pipefail

MOUNT_TARGET="/usr/palm/applications/com.webos.app.screensaver/qml/main.qml"
QML_PATH="$(basename "$0")/screensaver-main.qml"
QML_PATH="$(dirname "$0")/screensaver-main.qml"

if [[ ! -f "$MOUNT_TARGET" ]]; then
echo "[-] Target file does not exist: $MOUNT_TARGET" >&2
Expand Down
Binary file added assets/icon130.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/icon80.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 13 additions & 0 deletions frontend/App.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/**
Define your enyo/Application kind in this file.
*/

var
kind = require('enyo/kind'),
Application = require('enyo/Application'),
MainView = require('./views/MainView');

module.exports = kind({
kind: Application,
view: MainView
});
13 changes: 13 additions & 0 deletions frontend/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/**
Instantiate your enyo/Application kind in this file. Note, application
rendering should be deferred until the DOM is ready by wrapping it in a
call to ready().
*/

var
ready = require('enyo/ready'),
App = require('./App');

ready(function () {
new App();
});
98 changes: 98 additions & 0 deletions frontend/views/MainPanel.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
var
kind = require('enyo/kind'),
Panel = require('moonstone/Panel'),
FittableRows = require('layout/FittableRows'),
FittableColumns = require('layout/FittableColumns'),
BodyText = require('moonstone/BodyText'),
Marquee = require('moonstone/Marquee'),
LunaService = require('enyo-webos/LunaService'),
Divider = require('moonstone/Divider'),
Scroller = require('moonstone/Scroller'),
Item = require('moonstone/Item'),
ToggleItem = require('moonstone/ToggleItem'),
Group = require('enyo/Group');

var basePath = "/media/developer/apps/usr/palm/applications/org.webosbrew.custom-screensaver";
var applyPath = basePath + "/assets/apply.sh";
var linkPath = "/var/lib/webosbrew/init.d/50-custom-screensaver";
module.exports = kind({
name: 'MainPanel',
kind: Panel,
title: 'webOS Custom Screensaver',
titleBelow: "webosbrew.org",
headerType: 'medium',
components: [
{kind: FittableColumns, classes: 'enyo-center', fit: true, components: [
{kind: Scroller, fit: true, components: [
{classes: 'moon-hspacing', controlClasses: 'moon-12h', components: [
{components: [
// {kind: Divider, content: 'Toggle Items'},
{kind: ToggleItem, name: "autostart", content: 'Autostart', checked: true, disabled: true, onchange: "autostartToggle"},
{kind: Item, components: [
{kind: Marquee.Text, content: 'Apply temporarily'},
{kind: BodyText, style: 'margin: 10px 0', content: 'This will only enable custom screensaver until a reboot'},
], ontap: "temporaryApply"},
{kind: Item, content: 'Test run screensaver', ontap: "testRun"},
]},
]},
]},
]},
{components: [
{kind: Divider, content: 'Result'},
{kind: BodyText, name: 'result', content: 'Nothing selected...'}
]},
{kind: LunaService, name: 'statusCheck', service: 'luna://org.webosbrew.hbchannel.service', method: 'exec', onResponse: 'onStatusCheck', onError: 'onStatusCheck'},
{kind: LunaService, name: 'exec', service: 'luna://org.webosbrew.hbchannel.service', method: 'exec', onResponse: 'onExec', onError: 'onExec'},
],

bindings: [],

create: function () {
this.inherited(arguments);
this.$.statusCheck.send({
command: 'readlink ' + linkPath,
});
},

testRun: function (command) {
this.exec("luna-send -n 1 'luna://com.webos.service.tvpower/power/turnOnScreenSaver' '{}'");
},

temporaryApply: function (command) {
this.exec(applyPath);
},

exec: function (command) {
console.info(command);
this.$.result.set('content', 'Processing...');
this.$.exec.send({
command: command,
});
},

onExec: function (sender, evt) {
console.info(evt);
if (evt.returnValue) {
this.$.result.set('content', 'Success!<br />' + evt.stdoutString + evt.stderrString);
} else {
this.$.result.set('content', 'Failed: ' + evt.errorText + ' ' + evt.stdoutString + evt.stderrString);
}
},

onStatusCheck: function (sender, evt) {
console.info(sender, evt);
// this.$.result.set('content', JSON.stringify(evt.data));
this.$.autostart.set('disabled', false);
this.$.autostart.set('checked', evt.stdoutString && evt.stdoutString.trim() == applyPath);
},

autostartToggle: function (sender) {
console.info("toggle:", sender);

if (sender.active) {
this.exec('mkdir -p /var/lib/webosbrew/init.d && ln -sf ' + applyPath + ' ' + linkPath);
} else {
this.exec('rm -rf ' + linkPath);
}
},
});
37 changes: 37 additions & 0 deletions frontend/views/MainView.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
var
kind = require('enyo/kind'),
Panels = require('moonstone/Panels'),
IconButton = require('moonstone/IconButton'),
MainPanel = require('./MainPanel.js');

module.exports = kind({
name: 'myapp.MainView',
classes: 'moon enyo-fit main-view',
components: [
{
kind: Panels,
pattern: 'activity',
hasCloseButton: false,
wrap: true,
popOnBack: true,
components: [
{
kind: MainPanel,
},
],
onTransitionFinish: 'transitionFinish',
}
],
create: function () {
this.inherited(arguments);
},
handlers: {
onRequestPushPanel: 'requestPushPanel',
},
transitionFinish: function (evt, sender) {
document.title = this.$.panels.getActive().title;
},
requestPushPanel: function (sender, ev) {
this.$.panels.pushPanel(ev.panel);
},
});
1 change: 1 addition & 0 deletions lib/enyo
Submodule enyo added at 514d96
Loading

0 comments on commit 31b95ab

Please sign in to comment.