File tree 2 files changed +29
-1
lines changed
source/linux/background-managers
2 files changed +29
-1
lines changed Original file line number Diff line number Diff line change @@ -13,5 +13,6 @@ module.exports = {
13
13
qdbus : require ( './qdbus.js' ) ,
14
14
setroot : require ( './setroot.js' ) ,
15
15
xfconfquery : require ( './xfconf-query.js' ) ,
16
- swaybg : require ( './swaybg.js' )
16
+ swaybg : require ( './swaybg.js' ) ,
17
+ swww : require ( './swww.js' )
17
18
} ;
Original file line number Diff line number Diff line change
1
+ 'use strict' ;
2
+ const { commandExists, execFile} = require ( '../util.js' ) ;
3
+
4
+ exports . isAvailable = ( ) => commandExists ( 'swww' ) ;
5
+
6
+ async function initialize ( ) {
7
+ try {
8
+ await execFile ( 'swww' , [ 'init' ] ) ;
9
+ } catch ( error ) {
10
+ if ( error . stderr . includes ( 'There seems to already be another instance running' ) ) {
11
+ return ;
12
+ }
13
+
14
+ throw new Error ( `Failed to set image for swww: ${ error . stderr } ` ) ;
15
+ }
16
+ } ;
17
+
18
+ exports . get = async ( ) => {
19
+ await initialize ( ) ;
20
+ const { stdout : query } = await execFile ( 'swww' , [ 'query' ] ) ;
21
+ return query . slice ( query . indexOf ( '/' ) , query . indexOf ( '\n' ) ) ;
22
+ } ;
23
+
24
+ exports . set = async imagePath => {
25
+ await initialize ( ) ;
26
+ await execFile ( 'swww' , [ 'img' , imagePath ] ) ;
27
+ } ;
You can’t perform that action at this time.
0 commit comments