Skip to content

Commit 5a3f3a9

Browse files
committed
using artwork config as extra replacement params
1 parent bd431a0 commit 5a3f3a9

2 files changed

Lines changed: 28 additions & 2 deletions

File tree

extension.js

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,10 @@ module.exports = new Extension({
1818
'start_command': function(args, tokens) {
1919
// 1. clone template .xinitrc
2020
var filePath = _cloneTemplate(this.xinitrcTplPath);
21+
// 1. parse options from args into tokens
22+
var _tokens = _extendTokens(args, tokens);
2123
// 1. replace tokens in .xinitrc
22-
_replaceTokens(filePath, tokens);
24+
_replaceTokens(filePath, _tokens);
2325
// 2. return xinit
2426
return 'xinit ' + filePath;
2527
},
@@ -28,6 +30,30 @@ module.exports = new Extension({
2830
},
2931
});
3032

33+
/**
34+
* extend the tokens with expected values from args
35+
*
36+
* @param {object} args Arguments provided to this extension
37+
* @param {object} tokens Original tokens for this extension
38+
*/
39+
function _extendTokens(args, tokens){
40+
var _tokens = {};
41+
// shallow-copy the original tokens object
42+
for (var key in tokens){
43+
_tokens[key] = tokens[key];
44+
}
45+
46+
// copy expected arguments from args to the new tokens object
47+
// defaulting to an emptystring
48+
var expectedKeys = ['flags'];
49+
for (var key of expectedKeys){
50+
// prepend keys with a dollar-sign for template-replacement
51+
_tokens['$'+key] = args[key] || '';
52+
}
53+
54+
return _tokens;
55+
}
56+
3157
/**
3258
* Replace tokens in a file.
3359
*

scripts/.xinitrc.tpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ xset s noblank
66

77
unclutter -idle 0.1 &
88

9-
exec /usr/bin/chromium --noerrdialogs --kiosk --incognito "$url"
9+
exec /usr/bin/chromium --noerrdialogs --kiosk --incognito $flags "$url"

0 commit comments

Comments
 (0)