forked from Shinonome/dots-hyprland
fix invert shader toggle (#150)
This commit is contained in:
@@ -1,11 +1,22 @@
|
|||||||
|
const { GLib } = imports.gi;
|
||||||
import { Widget, Utils, Service } from '../../imports.js';
|
import { Widget, Utils, Service } from '../../imports.js';
|
||||||
import Bluetooth from 'resource:///com/github/Aylur/ags/service/bluetooth.js';
|
import Bluetooth from 'resource:///com/github/Aylur/ags/service/bluetooth.js';
|
||||||
import Network from 'resource:///com/github/Aylur/ags/service/network.js';
|
import Network from 'resource:///com/github/Aylur/ags/service/network.js';
|
||||||
|
import Hyprland from 'resource:///com/github/Aylur/ags/service/hyprland.js';
|
||||||
const { execAsync, exec } = Utils;
|
const { execAsync, exec } = Utils;
|
||||||
import { BluetoothIndicator, NetworkIndicator } from "../../lib/statusicons.js";
|
import { BluetoothIndicator, NetworkIndicator } from "../../lib/statusicons.js";
|
||||||
import { setupCursorHover } from "../../lib/cursorhover.js";
|
import { setupCursorHover } from "../../lib/cursorhover.js";
|
||||||
import { MaterialIcon } from '../../lib/materialicon.js';
|
import { MaterialIcon } from '../../lib/materialicon.js';
|
||||||
|
|
||||||
|
function expandTilde(path) {
|
||||||
|
if (path.startsWith('~')) {
|
||||||
|
console.log(GLib.get_home_dir() + path.slice(1));
|
||||||
|
return GLib.get_home_dir() + path.slice(1);
|
||||||
|
} else {
|
||||||
|
return path;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export const ToggleIconWifi = (props = {}) => Widget.Button({
|
export const ToggleIconWifi = (props = {}) => Widget.Button({
|
||||||
className: 'txt-small sidebar-iconbutton',
|
className: 'txt-small sidebar-iconbutton',
|
||||||
tooltipText: 'Wifi | Right-click to configure',
|
tooltipText: 'Wifi | Right-click to configure',
|
||||||
@@ -95,15 +106,22 @@ export const ModuleInvertColors = (props = {}) => Widget.Button({
|
|||||||
className: 'txt-small sidebar-iconbutton',
|
className: 'txt-small sidebar-iconbutton',
|
||||||
tooltipText: 'Color inversion',
|
tooltipText: 'Color inversion',
|
||||||
onClicked: (button) => {
|
onClicked: (button) => {
|
||||||
const shaderPath = JSON.parse(exec('hyprctl -j getoption decoration:screen_shader')).str;
|
// const shaderPath = JSON.parse(exec('hyprctl -j getoption decoration:screen_shader')).str;
|
||||||
if (shaderPath != "[[EMPTY]]" && shaderPath != "") {
|
Hyprland.sendMessage('j/getoption decoration:screen_shader')
|
||||||
execAsync(['bash', '-c', `hyprctl keyword decoration:screen_shader ''`]).catch(print);
|
.then((output) => {
|
||||||
button.toggleClassName('sidebar-button-active', false);
|
const shaderPath = JSON.parse(output)["str"].trim();
|
||||||
}
|
console.log(output)
|
||||||
else {
|
console.log(shaderPath)
|
||||||
execAsync(['bash', '-c', `hyprctl keyword decoration:screen_shader ~/.config/hypr/shaders/invert.frag`]).catch(print);
|
if (shaderPath != "[[EMPTY]]" && shaderPath != "") {
|
||||||
button.toggleClassName('sidebar-button-active', true);
|
execAsync(['bash', '-c', `hyprctl keyword decoration:screen_shader '[[EMPTY]]'`]).catch(print);
|
||||||
}
|
button.toggleClassName('sidebar-button-active', false);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Hyprland.sendMessage(`j/keyword decoration:screen_shader ${expandTilde('~/.config/hypr/shaders/invert.frag')}`)
|
||||||
|
.catch(print);
|
||||||
|
button.toggleClassName('sidebar-button-active', true);
|
||||||
|
}
|
||||||
|
})
|
||||||
},
|
},
|
||||||
child: MaterialIcon('invert_colors', 'norm'),
|
child: MaterialIcon('invert_colors', 'norm'),
|
||||||
setup: setupCursorHover,
|
setup: setupCursorHover,
|
||||||
|
|||||||
Reference in New Issue
Block a user