forked from Shinonome/dots-hyprland
save ai options
This commit is contained in:
@@ -6,103 +6,8 @@ const { Box, Button, Icon, Label, Scrollable, Slider, Stack, Overlay } = Widget;
|
||||
const { execAsync, exec } = Utils;
|
||||
import { MaterialIcon } from '../../.commonwidgets/materialicon.js';
|
||||
import { setupCursorHover } from '../../.widgetutils/cursorhover.js';
|
||||
import { ConfigGap, ConfigSpinButton, ConfigToggle } from '../../.commonwidgets/configwidgets.js';
|
||||
import { getNestedProperty, updateNestedProperty } from '../../.miscutils/objects.js';
|
||||
|
||||
const HyprlandToggle = ({ icon, name, desc = null, option, enableValue = 1, disableValue = 0, extraOnChange = () => { }, extraOnReset = () => { }, save = true }) => ConfigToggle({
|
||||
icon: icon,
|
||||
name: name,
|
||||
desc: desc,
|
||||
resetButton: true,
|
||||
initValue: JSON.parse(exec(`hyprctl getoption -j ${option}`))["int"] != 0,
|
||||
fetchValue: () => JSON.parse(exec(`hyprctl getoption -j ${option}`))["int"] != 0,
|
||||
onChange: (self, newValue) => {
|
||||
if (save)
|
||||
execAsync(['bash', '-c', `${App.configDir}/scripts/hyprland/hyprconfigurator.py \
|
||||
--key ${option} \
|
||||
--value ${newValue ? enableValue : disableValue} \
|
||||
--file \${XDG_CONFIG_HOME:-$HOME/.config}/hypr/custom/general.conf`
|
||||
]).catch(print);
|
||||
else
|
||||
execAsync(['hyprctl', 'keyword', option, `${newValue ? enableValue : disableValue}`]).catch(print);
|
||||
|
||||
extraOnChange(self, newValue);
|
||||
},
|
||||
onReset: async (self) => {
|
||||
if (save)
|
||||
exec(`bash -c '${App.configDir}/scripts/hyprland/hyprconfigurator.py \
|
||||
--key ${option} \
|
||||
--reset \
|
||||
--file "\${XDG_CONFIG_HOME:-$HOME/.config}/hypr/custom/general.conf"'`);
|
||||
else
|
||||
exec('hyprctl reload')
|
||||
extraOnReset(self);
|
||||
},
|
||||
});
|
||||
|
||||
const HyprlandSpinButton = ({ icon, name, desc = null, option, save = true, extraOnChange = () => { }, extraOnReset = () => { }, ...rest }) => ConfigSpinButton({
|
||||
icon: icon,
|
||||
name: name,
|
||||
desc: desc,
|
||||
resetButton: true,
|
||||
initValue: Number(JSON.parse(exec(`hyprctl getoption -j ${option}`))["int"]),
|
||||
fetchValue: () => Number(JSON.parse(exec(`hyprctl getoption -j ${option}`))["int"]),
|
||||
onChange: (self, newValue) => {
|
||||
if (save)
|
||||
execAsync(['bash', '-c', `${App.configDir}/scripts/hyprland/hyprconfigurator.py \
|
||||
--key ${option} \
|
||||
--value ${newValue} \
|
||||
--file \${XDG_CONFIG_HOME:-$HOME/.config}/hypr/custom/general.conf`
|
||||
]).catch(print);
|
||||
else
|
||||
execAsync(['hyprctl', 'keyword', option, `${newValue}`]).catch(print);
|
||||
|
||||
extraOnChange(self, newValue);
|
||||
},
|
||||
onReset: async (self) => {
|
||||
if (save)
|
||||
exec(`bash -c '${App.configDir}/scripts/hyprland/hyprconfigurator.py \
|
||||
--key ${option} \
|
||||
--reset \
|
||||
--file "\${XDG_CONFIG_HOME:-$HOME/.config}/hypr/custom/general.conf"'`);
|
||||
else
|
||||
exec('hyprctl reload')
|
||||
extraOnReset(self);
|
||||
},
|
||||
...rest,
|
||||
});
|
||||
|
||||
const AgsSpinButton = ({
|
||||
icon, name, desc = null, option,
|
||||
save = true, extraOnChange = () => { },
|
||||
...rest
|
||||
}) => ConfigSpinButton({
|
||||
icon: icon,
|
||||
name: name,
|
||||
desc: desc,
|
||||
resetButton: true,
|
||||
initValue: getNestedProperty(userOptions, option),
|
||||
fetchValue: () => getNestedProperty(userOptions, option),
|
||||
step: 10, minValue: 0, maxValue: 1000,
|
||||
onChange: (self, newValue) => {
|
||||
updateNestedProperty(userOptions, option, newValue);
|
||||
if (save) execAsync(['bash', '-c', `${App.configDir}/scripts/ags/agsconfigurator.py \
|
||||
--key ${option} \
|
||||
--value ${newValue} \
|
||||
--file ${App.configDir}/user_options.jsonc`
|
||||
]).catch(print);
|
||||
extraOnChange(self, newValue);
|
||||
},
|
||||
onReset: async (self) => {
|
||||
updateNestedProperty(userOptions, option,
|
||||
getNestedProperty(userOptionsDefaults, option));
|
||||
if (save) exec(`bash -c '${App.configDir}/scripts/ags/agsconfigurator.py \
|
||||
--key ${option} \
|
||||
--reset \
|
||||
--file ${App.configDir}/user_options.jsonc'`);
|
||||
},
|
||||
...rest,
|
||||
})
|
||||
import { ConfigGap, ConfigToggle } from '../../.commonwidgets/configwidgets.js';
|
||||
import { AgsSpinButton, HyprlandSpinButton, HyprlandToggle } from '../../.commonwidgets/configwidgets_apps.js';
|
||||
|
||||
const Subcategory = (children) => Box({
|
||||
className: 'margin-left-20',
|
||||
|
||||
Reference in New Issue
Block a user