File tree 2 files changed +18
-4
lines changed
source/linux/background-managers
2 files changed +18
-4
lines changed Original file line number Diff line number Diff line change 1
1
'use strict' ;
2
- const { commandExists, execFile} = require ( '../util.js' ) ;
2
+ const { commandExists, execFile, hasLine } = require ( '../util.js' ) ;
3
3
4
4
exports . isAvailable = ( ) => commandExists ( 'gsettings' ) ;
5
5
6
+ async function isDarkStyle ( ) {
7
+ const { stdout} = await execFile ( 'gsettings' , [
8
+ 'get' ,
9
+ 'org.gnome.desktop.interface' ,
10
+ 'color-scheme' ,
11
+ ] ) ;
12
+
13
+ return Boolean ( hasLine ( stdout , '\'prefer-dark\'' ) ) ;
14
+ }
15
+
6
16
exports . set = async imagePath => {
17
+ const keyForStyle = ( await isDarkStyle ( ) ) ? 'picture-uri-dark' : 'picture-uri' ;
18
+
7
19
await execFile ( 'gsettings' , [
8
20
'set' ,
9
21
'org.gnome.desktop.background' ,
10
- 'picture-uri' ,
22
+ keyForStyle ,
11
23
`file://${ imagePath } `
12
24
] ) ;
13
25
} ;
14
26
15
27
exports . get = async ( ) => {
28
+ const keyForStyle = ( await isDarkStyle ( ) ) ? 'picture-uri-dark' : 'picture-uri' ;
29
+
16
30
const { stdout} = await execFile ( 'gsettings' , [
17
31
'get' ,
18
32
'org.gnome.desktop.background' ,
19
- 'picture-uri'
33
+ keyForStyle
20
34
] ) ;
21
35
22
36
return stdout . trim ( ) . slice ( 8 , - 1 ) ;
Original file line number Diff line number Diff line change @@ -13,7 +13,7 @@ async function initialize() {
13
13
14
14
throw new Error ( `Failed to set image for swww: ${ error . stderr } ` ) ;
15
15
}
16
- } ;
16
+ }
17
17
18
18
exports . get = async ( ) => {
19
19
await initialize ( ) ;
You can’t perform that action at this time.
0 commit comments