-
-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
1. Battery material colors 2. Some changes
- Loading branch information
Showing
13 changed files
with
229 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
const { GLib } = imports.gi; | ||
|
||
export const default_config = { | ||
"always_show_battery": false, | ||
"show_taskbar": true, | ||
"show_battery_percent": true, | ||
} | ||
|
||
|
||
Utils.exec(["mkdir", "-p", `${GLib.get_home_dir()}/.config/ags_config/`]) | ||
const config_file = `${GLib.get_home_dir()}/.config/ags_config/conf.json`; | ||
if (Utils.readFile(config_file).length < 2) { | ||
Utils.writeFileSync(JSON.stringify(default_config), config_file) | ||
} | ||
|
||
class ConfigService extends Service { | ||
static { | ||
Service.register( | ||
this, | ||
{ | ||
'config-changed': ['jsobject'], | ||
}, | ||
{ | ||
'config': ['jsobject', 'rw'], | ||
}, | ||
); | ||
} | ||
|
||
#config = default_config; | ||
#config_file = config_file; | ||
|
||
get config() { | ||
return this.#config; | ||
} | ||
|
||
set config(conf) { | ||
Utils.writeFile(JSON.stringify(conf), this.#config_file).catch(print) | ||
} | ||
|
||
constructor() { | ||
super(); | ||
|
||
const config_file = this.#config_file; | ||
Utils.monitorFile(config_file, () => this.#onChange()); | ||
|
||
this.#onChange(); | ||
} | ||
|
||
#onChange() { | ||
Utils.readFileAsync(this.#config_file) | ||
.then(out => { | ||
this.#config = {...default_config, ...JSON.parse(out)} | ||
this.emit('changed'); | ||
this.notify('config'); | ||
|
||
this.emit('config-changed', this.#config); | ||
}) | ||
} | ||
|
||
connect(event = 'config-changed', callback) { | ||
return super.connect(event, callback); | ||
} | ||
} | ||
|
||
const service = new ConfigService; | ||
|
||
export default service; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters