forked from Shinonome/dots-hyprland
Hyprland gamemode toggle (#1094)
This commit is contained in:
@@ -115,6 +115,9 @@ let configOptions = {
|
|||||||
'order': ["gemini", "gpt", "waifu", "booru"],
|
'order': ["gemini", "gpt", "waifu", "booru"],
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
'quickToggles': {
|
||||||
|
'order': ["wifi", "bluetooth", "nightlight", "gamemode", "idleinhibitor", "cloudflarewarp"],
|
||||||
|
}
|
||||||
},
|
},
|
||||||
'search': {
|
'search': {
|
||||||
'enableFeatures': {
|
'enableFeatures': {
|
||||||
|
|||||||
@@ -203,6 +203,33 @@ export const ModuleRawInput = async (props = {}) => {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const ModuleGameMode = async (props = {}) => {
|
||||||
|
try {
|
||||||
|
const Hyprland = (await import('resource:///com/github/Aylur/ags/service/hyprland.js')).default;
|
||||||
|
return Widget.Button({
|
||||||
|
className: 'txt-small sidebar-iconbutton',
|
||||||
|
tooltipText: getString('Hyprland Game Mode'),
|
||||||
|
onClicked: (button) => {
|
||||||
|
Utils.execAsync(`hyprctl -j getoption animations:enabled`)
|
||||||
|
.then((output) => {
|
||||||
|
const enabled = JSON.parse(output)["int"] === 1;
|
||||||
|
if (enabled) {
|
||||||
|
execAsync(['bash', '-c', `hyprctl --batch "keyword animations:enabled 0; keyword decoration:shadow:enabled 0; keyword decoration:blur:enabled 0; keyword general:gaps_in 0; keyword general:gaps_out 0; keyword general:border_size 1; keyword decoration:rounding 0; keyword general:allow_tearing 1"`]).catch(print);
|
||||||
|
} else {
|
||||||
|
execAsync(['bash', '-c', `hyprctl reload`]).catch(print);
|
||||||
|
}
|
||||||
|
button.toggleClassName('sidebar-button-active', enabled);
|
||||||
|
})
|
||||||
|
},
|
||||||
|
child: MaterialIcon('gamepad', 'norm'),
|
||||||
|
setup: setupCursorHover,
|
||||||
|
...props,
|
||||||
|
})
|
||||||
|
} catch {
|
||||||
|
return null;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
export const ModuleIdleInhibitor = (props = {}) => Widget.Button({ // TODO: Make this work
|
export const ModuleIdleInhibitor = (props = {}) => Widget.Button({ // TODO: Make this work
|
||||||
attribute: {
|
attribute: {
|
||||||
enabled: false,
|
enabled: false,
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ import {
|
|||||||
ModuleSettingsIcon,
|
ModuleSettingsIcon,
|
||||||
ModulePowerIcon,
|
ModulePowerIcon,
|
||||||
ModuleRawInput,
|
ModuleRawInput,
|
||||||
|
ModuleGameMode,
|
||||||
ModuleCloudflareWarp
|
ModuleCloudflareWarp
|
||||||
} from "./quicktoggles.js";
|
} from "./quicktoggles.js";
|
||||||
import ModuleNotificationList from "./centermodules/notificationlist.js";
|
import ModuleNotificationList from "./centermodules/notificationlist.js";
|
||||||
@@ -26,6 +27,18 @@ import { MaterialIcon } from '../.commonwidgets/materialicon.js';
|
|||||||
import { ExpandingIconTabContainer } from '../.commonwidgets/tabcontainer.js';
|
import { ExpandingIconTabContainer } from '../.commonwidgets/tabcontainer.js';
|
||||||
import { checkKeybind } from '../.widgetutils/keybind.js';
|
import { checkKeybind } from '../.widgetutils/keybind.js';
|
||||||
|
|
||||||
|
const QUICK_TOGGLES = {
|
||||||
|
'wifi': ToggleIconWifi(),
|
||||||
|
'bluetooth': ToggleIconBluetooth(),
|
||||||
|
'rawinput': await ModuleRawInput(),
|
||||||
|
'touchpad': await HyprToggleIcon('touchpad_mouse', 'No touchpad while typing', 'input:touchpad:disable_while_typing', {}),
|
||||||
|
'nightlight': await ModuleNightLight(),
|
||||||
|
'invertcolors': await ModuleInvertColors(),
|
||||||
|
'gamemode': await ModuleGameMode(),
|
||||||
|
'idleinhibitor': ModuleIdleInhibitor(),
|
||||||
|
'cloudflarewarp': await ModuleCloudflareWarp(),
|
||||||
|
}
|
||||||
|
|
||||||
const centerWidgets = [
|
const centerWidgets = [
|
||||||
{
|
{
|
||||||
name: getString('Notifications'),
|
name: getString('Notifications'),
|
||||||
@@ -118,16 +131,7 @@ const timeRow = Box({
|
|||||||
const togglesBox = Widget.Box({
|
const togglesBox = Widget.Box({
|
||||||
hpack: 'center',
|
hpack: 'center',
|
||||||
className: 'sidebar-togglesbox spacing-h-5',
|
className: 'sidebar-togglesbox spacing-h-5',
|
||||||
children: [
|
children: userOptions.sidebar.quickToggles.order.map(toggle => QUICK_TOGGLES[toggle])
|
||||||
ToggleIconWifi(),
|
|
||||||
ToggleIconBluetooth(),
|
|
||||||
// await ModuleRawInput(),
|
|
||||||
// await HyprToggleIcon('touchpad_mouse', 'No touchpad while typing', 'input:touchpad:disable_while_typing', {}),
|
|
||||||
await ModuleNightLight(),
|
|
||||||
await ModuleInvertColors(),
|
|
||||||
ModuleIdleInhibitor(),
|
|
||||||
await ModuleCloudflareWarp(),
|
|
||||||
]
|
|
||||||
})
|
})
|
||||||
|
|
||||||
export const sidebarOptionsStack = ExpandingIconTabContainer({
|
export const sidebarOptionsStack = ExpandingIconTabContainer({
|
||||||
|
|||||||
Reference in New Issue
Block a user