diff --git a/js/App.js b/js/App.js index dbe667f..7a3845c 100644 --- a/js/App.js +++ b/js/App.js @@ -40,5 +40,8 @@ app.config.globalProperties.$systeminformation = require('systeminformation'); app.config.globalProperties.$win = nw.Window.get(); app.config.globalProperties.$pid = process.pid; app.config.globalProperties.$screen = screen; +app.config.globalProperties.$getIcon = (icon) => { + return app.config.globalProperties.$execSynx('python', ['/usr/share/vasak-desktop-service/Vasak/getIcon.py', icon]).stdout.toString(); +}; app.mount('#app'); diff --git a/js/components/MenuButtom.js b/js/components/MenuButtom.js index 99057e4..a8746a4 100644 --- a/js/components/MenuButtom.js +++ b/js/components/MenuButtom.js @@ -6,10 +6,7 @@ export default { }, computed: { icon() { - return this.$execSynx('python', [ - '/usr/share/vasak-desktop-service/Vasak/getIcon.py', - 'hydriam', - ]).stdout.toString(); + return this.$getIcon('hydriam'); }, }, template: ` diff --git a/js/components/notificationtools/BatteryIndicator.js b/js/components/notificationtools/BatteryIndicator.js index db5b22e..9632bde 100644 --- a/js/components/notificationtools/BatteryIndicator.js +++ b/js/components/notificationtools/BatteryIndicator.js @@ -1,7 +1,7 @@ export default { data() { return { - icon: this.$execSynx('python', ['/usr/share/vasak-desktop-service/Vasak/getIcon.py', 'battery-missing-symbolic']).stdout.toString(), + icon: this.$getIcon('battery-missing-symbolic'), percent: 0 }; }, @@ -15,49 +15,49 @@ export default { this.percent = batteryInfo.percent; if (batteryInfo.isCharging) { if (batteryInfo.percent === 100) { - this.icon = this.$execSynx('python', ['/usr/share/vasak-desktop-service/Vasak/getIcon.py', 'battery-full-charging-symbolic']).stdout.toString(); + this.icon = this.$getIcon('battery-full-charging-symbolic'); } else if (batteryInfo.percent > 90) { - this.icon = this.$execSynx('python', ['/usr/share/vasak-desktop-service/Vasak/getIcon.py', 'battery-level-90-charging-symbolic']).stdout.toString(); + this.icon = this.$getIcon('battery-level-90-charging-symbolic'); } else if (batteryInfo.percent > 80) { - this.icon = this.$execSynx('python', ['/usr/share/vasak-desktop-service/Vasak/getIcon.py', 'battery-level-80-charging-symbolic']).stdout.toString(); + this.icon = this.$getIcon('battery-level-80-charging-symbolic'); } else if (batteryInfo.percent > 70) { - this.icon = this.$execSynx('python', ['/usr/share/vasak-desktop-service/Vasak/getIcon.py', 'battery-level-70-charging-symbolic']).stdout.toString(); + this.icon = this.$getIcon('battery-level-70-charging-symbolic'); } else if (batteryInfo.percent > 60) { - this.icon = this.$execSynx('python', ['/usr/share/vasak-desktop-service/Vasak/getIcon.py', 'battery-level-60-charging-symbolic']).stdout.toString(); + this.icon = this.$getIcon('battery-level-60-charging-symbolic'); } else if (batteryInfo.percent > 50) { - this.icon = this.$execSynx('python', ['/usr/share/vasak-desktop-service/Vasak/getIcon.py', 'battery-level-50-charging-symbolic']).stdout.toString(); + this.icon = this.$getIcon('battery-level-50-charging-symbolic'); } else if (batteryInfo.percent > 40) { - this.icon = this.$execSynx('python', ['/usr/share/vasak-desktop-service/Vasak/getIcon.py', 'battery-level-40-charging-symbolic']).stdout.toString(); + this.icon = this.$getIcon('battery-level-40-charging-symbolic'); } else if (batteryInfo.percent > 30) { - this.icon = this.$execSynx('python', ['/usr/share/vasak-desktop-service/Vasak/getIcon.py', 'battery-level-30-charging-symbolic']).stdout.toString(); + this.icon = this.$getIcon('battery-level-30-charging-symbolic'); } else if (batteryInfo.percent > 20) { - this.icon = this.$execSynx('python', ['/usr/share/vasak-desktop-service/Vasak/getIcon.py', 'battery-level-20-charging-symbolic']).stdout.toString(); + this.icon = this.$getIcon('battery-level-20-charging-symbolic'); } else { - this.icon = this.$execSynx('python', ['/usr/share/vasak-desktop-service/Vasak/getIcon.py', 'battery-level-10-charging-symbolic']).stdout.toString(); + this.icon = this.$getIcon('battery-level-10-charging-symbolic'); } } else { if (batteryInfo.percent === 100) { - this.icon = this.$execSynx('python', ['/usr/share/vasak-desktop-service/Vasak/getIcon.py', 'battery-full-symbolic']).stdout.toString(); + this.icon = this.$getIcon('battery-full-symbolic'); } else if (batteryInfo.percent > 90) { - this.icon = this.$execSynx('python', ['/usr/share/vasak-desktop-service/Vasak/getIcon.py', 'battery-level-90-symbolic']).stdout.toString(); + this.icon = this.$getIcon('battery-level-90-symbolic'); } else if (batteryInfo.percent > 80) { - this.icon = this.$execSynx('python', ['/usr/share/vasak-desktop-service/Vasak/getIcon.py', 'battery-level-80-symbolic']).stdout.toString(); + this.icon = this.$getIcon('battery-level-80-symbolic'); } else if (batteryInfo.percent > 70) { - this.icon = this.$execSynx('python', ['/usr/share/vasak-desktop-service/Vasak/getIcon.py', 'battery-level-70-symbolic']).stdout.toString(); + this.icon = this.$getIcon('battery-level-70-symbolic'); } else if (batteryInfo.percent > 60) { - this.icon = this.$execSynx('python', ['/usr/share/vasak-desktop-service/Vasak/getIcon.py', 'battery-level-60-symbolic']).stdout.toString(); + this.icon = this.$getIcon('battery-level-60-symbolic'); } else if (batteryInfo.percent > 50) { - this.icon = this.$execSynx('python', ['/usr/share/vasak-desktop-service/Vasak/getIcon.py', 'battery-level-50-symbolic']).stdout.toString(); + this.icon = this.$getIcon('battery-level-50-symbolic'); } else if (batteryInfo.percent > 40) { - this.icon = this.$execSynx('python', ['/usr/share/vasak-desktop-service/Vasak/getIcon.py', 'battery-level-40-symbolic']).stdout.toString(); + this.icon = this.$getIcon('battery-level-40-symbolic'); } else if (batteryInfo.percent > 30) { - this.icon = this.$execSynx('python', ['/usr/share/vasak-desktop-service/Vasak/getIcon.py', 'battery-level-30-symbolic']).stdout.toString(); + this.icon = this.$getIcon('battery-level-30-symbolic'); } else if (batteryInfo.percent > 20) { - this.icon = this.$execSynx('python', ['/usr/share/vasak-desktop-service/Vasak/getIcon.py', 'battery-level-20-symbolic']).stdout.toString(); + this.icon = this.$getIcon('battery-level-20-symbolic'); } else if (batteryInfo.percent > 10) { - this.icon = this.$execSynx('python', ['/usr/share/vasak-desktop-service/Vasak/getIcon.py', 'battery-level-10-symbolic']).stdout.toString(); + this.icon = this.$getIcon('battery-level-10-symbolic'); } else { - this.icon = this.$execSynx('python', ['/usr/share/vasak-desktop-service/Vasak/getIcon.py', 'battery-empty-symbolic']).stdout.toString(); + this.icon = this.$getIcon('battery-empty-symbolic'); } } } diff --git a/js/components/notificationtools/NetworkIndicator.js b/js/components/notificationtools/NetworkIndicator.js index 32f0717..5de4fdd 100644 --- a/js/components/notificationtools/NetworkIndicator.js +++ b/js/components/notificationtools/NetworkIndicator.js @@ -1,7 +1,7 @@ export default { data() { return { - icon: this.$execSynx('python', ['/usr/share/vasak-desktop-service/Vasak/getIcon.py', 'network-disconnected-symbolic']).stdout.toString(), + icon: this.$getIcon('network-disconnected-symbolic'), data: '127.0.0.1' }; }, @@ -15,13 +15,13 @@ export default { if (device.type === 'wired') { if (device.operstate === 'down') { - this.icon = this.$execSynx('python', ['/usr/share/vasak-desktop-service/Vasak/getIcon.py', 'network-wired-disconnected-symbolic']).stdout.toString(); + this.icon = this.$getIcon('network-wired-disconnected-symbolic'); } else { - this.icon = this.$execSynx('python', ['/usr/share/vasak-desktop-service/Vasak/getIcon.py', 'network-wired-symbolic']).stdout.toString(); + this.icon = this.$getIcon('network-wired-symbolic'); } } else { if (device.operstate === 'down') { - this.icon = this.$execSynx('python', ['/usr/share/vasak-desktop-service/Vasak/getIcon.py', 'network-wireless-disconnected-symbolic']).stdout.toString(); + this.icon = this.$getIcon('network-wireless-disconnected-symbolic'); } else { const wifi = await this.$systeminformation.wifiConnections(); const myWifi = wifi.find(conn => conn.iface === device.iface); @@ -29,15 +29,15 @@ export default { //elem.innerHTML = myWifi.signalLevel; if (myWifi.signalLevel >= -30) { - this.icon = this.$execSynx('python', ['/usr/share/vasak-desktop-service/Vasak/getIcon.py', 'network-wireless-signal-excellent-symbolic']).stdout.toString(); + this.icon = this.$getIcon('network-wireless-signal-excellent-symbolic'); } else if (myWifi.signalLevel >= -67) { - this.icon = this.$execSynx('python', ['/usr/share/vasak-desktop-service/Vasak/getIcon.py', 'network-wireless-signal-good-symbolic']).stdout.toString(); + this.icon = this.$getIcon('network-wireless-signal-good-symbolic'); } else if (myWifi.signalLevel >= -70) { - this.icon = this.$execSynx('python', ['/usr/share/vasak-desktop-service/Vasak/getIcon.py', 'network-wireless-signal-ok-symbolic']).stdout.toString(); + this.icon = this.$getIcon('network-wireless-signal-ok-symbolic'); } else if (myWifi.signalLevel >= -80) { - this.icon = this.$execSynx('python', ['/usr/share/vasak-desktop-service/Vasak/getIcon.py', 'network-wireless-signal-weak-symbolic']).stdout.toString(); + this.icon = this.$getIcon('network-wireless-signal-weak-symbolic'); } else { - this.icon = this.$execSynx('python', ['/usr/share/vasak-desktop-service/Vasak/getIcon.py', 'network-wireless-signal-none-symbolic']).stdout.toString(); + this.icon = this.$getIcon('network-wireless-signal-none-symbolic'); } } }