This repository contains the source code for a reddit wallpaper Tasker project.
Features:
- Wallpapers from latest best images in a subreddit.
- Updates wallpaper every x minutes
- Minimum resolution wallpapers.
- Offline and online modus.
- Never see a wallpaper twice (when online).
- Cached wallpapers (when offline).
- Notification with wallpaper title, buttons to skip wallpaper and to open post in browser.
The main project logic is written in Javascript inspired by TaskerJavaScriptHelpers. Similarly this repo contains a runner that runs Javascript as if it executed within Tasker and a builder that can be used to convert code for useage in a Tasker JavaScript action. Hats of for @StephenGregory for doing such a great writeup! This repo works very similarely with a few optimations:
- Es6 support by using webpack instead of browserify.
- Automatic re-running using nodemon.
- More Tasker Javascript functions are implemented.
- Tasker functions that are not implemented but are available throw an Error.
- Linting using Eslint.
- Testing using Jest.
This tasker project tries to implement all of its logic using Javascript, however as Tasker does not expose every action (nor profiles) a bit of Tasker "wizardry" is used.
2 profiles:
Refresh wallpaper
runs the script every x minutes.Notification Click
handles clicking on te notification.
3 Tasks:
Update Wallpaper
main tasks, only runs Javascript.Wallpaper Notification
implements the notify action for usage in Javascript.Open browser
handles opening links from the notification.
Latest version of the wallpaper script can be found in dist/index.min.js
and the Tasker project can be either imported using this DataUri or as xml:
<?xml version="1.0"?>
-<TaskerData tv="5.13.7" dvi="1" sr="">
-<Profile sr="prof2" ve="2">
<cdate>1627161030641</cdate>
<clp>true</clp>
<edate>1632000206254</edate>
<flags>8</flags>
<id>2</id>
<mid0>3</mid0>
<nme>Refresh Wallpaper</nme>
-<Time sr="con0">
<fh>7</fh>
<fm>0</fm>
<rep>2</rep>
<repval>30</repval>
<th>0</th>
<tm>0</tm>
</Time>
</Profile>
-<Profile sr="prof6" ve="2">
<cdate>1627676251521</cdate>
<edate>1636996530615</edate>
<flags>8</flags>
<id>6</id>
<mid0>5</mid0>
-<Event sr="con0" ve="2">
<code>2000</code>
<pri>0</pri>
-<App sr="arg0">
<appClass>net.dinglisch.android.taskerm.Tasker</appClass>
<appPkg>net.dinglisch.android.taskerm</appPkg>
<label>Tasker</label>
</App>
<Str sr="arg1" ve="3">Current Wallpaper</Str>
</Event>
</Profile>
-<Project sr="proj0" ve="2">
<cdate>1631004304769</cdate>
<name>Reddit wallpaper</name>
<pids>2,6</pids>
<tids>5,3,4</tids>
-<Kid sr="Kid">
<launchID>3</launchID>
<pkg>space.joep.tasker</pkg>
<vTarg>29</vTarg>
<vnme>1.0</vnme>
</Kid>
-<Img sr="icon" ve="2">
<nme>mw_action_perm_device_information</nme>
</Img>
</Project>
-<Task sr="task3">
<cdate>1627161039733</cdate>
<edate>1636996938022</edate>
<id>3</id>
<nme>Update Wallpaper</nme>
<pri>6</pri>
-<Action sr="act0" ve="7">
<code>131</code>
<Str sr="arg0" ve="3">Tasker/wallpaper/index.min.js</Str>
<Str sr="arg1" ve="3"/>
<Int sr="arg2" val="0"/>
<Int sr="arg3" val="45"/>
</Action>
</Task>
-<Task sr="task4">
<cdate>1627161197209</cdate>
<edate>1636994820900</edate>
<id>4</id>
<nme>WallpaperNotification</nme>
<rty>1</rty>
-<Action sr="act0" ve="7">
<code>523</code>
<Str sr="arg0" ve="3">Current Wallpaper</Str>
<Str sr="arg1" ve="3">%par1</Str>
<Str sr="arg10" ve="3"/>
<Str sr="arg11" ve="3">Wallpaper</Str>
-<Img sr="arg2" ve="2">
<nme>mw_action_perm_device_information</nme>
</Img>
<Int sr="arg3" val="0"/>
<Int sr="arg4" val="1"/>
<Int sr="arg5" val="3"/>
<Int sr="arg6" val="0"/>
<Int sr="arg7" val="0"/>
<Int sr="arg8" val="0"/>
<Str sr="arg9" ve="3"/>
-<ListElementItem sr="item0">
<label>Post</label>
-<Action sr="action" ve="7">
<code>130</code>
<Str sr="arg0" ve="3">Open Browser</Str>
-<Int sr="arg1">
<var>%priority</var>
</Int>
<Int sr="arg10" val="1"/>
<Str sr="arg2" ve="3">%par2</Str>
<Str sr="arg3" ve="3"/>
<Str sr="arg4" ve="3"/>
<Int sr="arg5" val="0"/>
<Int sr="arg6" val="0"/>
<Str sr="arg7" ve="3"/>
<Int sr="arg8" val="0"/>
<Int sr="arg9" val="0"/>
</Action>
</ListElementItem>
-<ListElementItem sr="item1">
<label>Next</label>
-<Action sr="action" ve="7">
<code>130</code>
<Str sr="arg0" ve="3">Update Wallpaper</Str>
-<Int sr="arg1">
<var>%priority</var>
</Int>
<Int sr="arg10" val="1"/>
<Str sr="arg2" ve="3"/>
<Str sr="arg3" ve="3"/>
<Str sr="arg4" ve="3"/>
<Int sr="arg5" val="0"/>
<Int sr="arg6" val="0"/>
<Str sr="arg7" ve="3"/>
<Int sr="arg8" val="0"/>
<Int sr="arg9" val="0"/>
</Action>
</ListElementItem>
</Action>
</Task>
-<Task sr="task5">
<cdate>1627162588926</cdate>
<edate>1636996530615</edate>
<id>5</id>
<nme>Open Browser</nme>
<pri>6</pri>
-<Action sr="act0" ve="7">
<code>512</code>
<Int sr="arg0" val="1"/>
</Action>
-<Action sr="act1" ve="7">
<code>547</code>
<Str sr="arg0" ve="3">%par1</Str>
<Str sr="arg1" ve="3">%WallpaperPostUrl</Str>
<Int sr="arg2" val="0"/>
<Int sr="arg3" val="0"/>
<Int sr="arg4" val="0"/>
<Int sr="arg5" val="3"/>
<Int sr="arg6" val="1"/>
-<ConditionList sr="if">
-<Condition sr="c0" ve="3">
<lhs>%par1</lhs>
<op>13</op>
<rhs/>
</Condition>
</ConditionList>
</Action>
-<Action sr="act2" ve="7">
<code>104</code>
<Str sr="arg0" ve="3">%par1</Str>
</Action>
</Task>
</TaskerData>
- Download and install the latest version of Git.
- Download and install the latest (not the LTS) version of NodeJS.
- Run
npm -g i npm
to get yourself the latest version of the npm package manager.
To check the tools have been set up properly, check that you can run git version
, node -v
and npm -v
from a command terminal.
Execute the following commands in the (new, empty) directory where you want to set up the project:
- Checkout the code:
git clone git@github.com:JoepSchyns/tasker-reddit-wallpaper.git .
- Install project dependencies:
npm install
- You can run
npm run build
to build a minified version for usage in tasker. - You can run
npm run serve
to start a development environment that will automatically rebuild changes. - You can run
npm run lint
to lint the source code. - You can run
npm run fix
to try and fix all linting issues automatically. - You can run
npm run test
to run all predefined tests.
By changing the constants found in src/helpers/constants.ts
you can alter things such as: subreddit, minimum resolution, reddit client, etc.
/dist/
contains files ready for use in Tasker./Docker/
TODO: a dockerized emulator for testing code on Android./src/
contains the main application source code.helpers/
contains helper functions used in multiple parts of the code.tasks/
contains main subroutines.Tasker.js
contains node implementations of Tasker Javascript functions.
Tasker/
Emulates the Tasker folder found in on the root of Android.test/
contains test scripts.