mirror of
https://github.com/end-4/dots-hyprland.git
synced 2026-06-06 07:19:27 -05:00
save ai options
This commit is contained in:
@@ -0,0 +1,150 @@
|
||||
import * as Utils from 'resource:///com/github/Aylur/ags/utils.js';
|
||||
const { execAsync, exec } = Utils;
|
||||
|
||||
import { getNestedProperty, updateNestedProperty } from "../.miscutils/objects.js";
|
||||
import { ConfigSpinButton, ConfigToggle } from "./configwidgets.js";
|
||||
|
||||
const AGS_CONFIG_FILE = `${App.configDir}/user_options.jsonc`;
|
||||
|
||||
export const AgsToggle = ({
|
||||
icon, name, desc = null,
|
||||
option, resetButton = true, save = true,
|
||||
extraOnChange = () => { }, extraOnReset = () => { },
|
||||
}) => ConfigToggle({
|
||||
icon: icon,
|
||||
name: name,
|
||||
desc: desc,
|
||||
resetButton: resetButton,
|
||||
initValue: getNestedProperty(userOptions, option),
|
||||
fetchValue: () => getNestedProperty(userOptions, option),
|
||||
onChange: (self, newValue) => {
|
||||
updateNestedProperty(userOptions, option, newValue);
|
||||
if (save) execAsync(['bash', '-c', `${App.configDir}/scripts/ags/agsconfigurator.py \
|
||||
--key ${option} \
|
||||
--value ${newValue} \
|
||||
--file ${AGS_CONFIG_FILE}`
|
||||
]).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 ${AGS_CONFIG_FILE}'`);
|
||||
extraOnReset(self);
|
||||
},
|
||||
});
|
||||
|
||||
export const AgsSpinButton = ({
|
||||
icon, name, desc = null,
|
||||
option, resetButton = true,
|
||||
save = true, extraOnChange = () => { }, extraOnReset = () => { },
|
||||
...rest
|
||||
}) => ConfigSpinButton({
|
||||
icon: icon,
|
||||
name: name,
|
||||
desc: desc,
|
||||
resetButton: resetButton,
|
||||
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 ${AGS_CONFIG_FILE}`
|
||||
]).catch(print);
|
||||
extraOnChange(self, newValue);
|
||||
},
|
||||
onReset: async () => {
|
||||
updateNestedProperty(userOptions, option,
|
||||
getNestedProperty(userOptionsDefaults, option));
|
||||
if (save) exec(`bash -c '${App.configDir}/scripts/ags/agsconfigurator.py \
|
||||
--key ${option} \
|
||||
--reset \
|
||||
--file ${AGS_CONFIG_FILE}'`);
|
||||
extraOnReset(self);
|
||||
},
|
||||
...rest,
|
||||
});
|
||||
|
||||
export const HyprlandToggle = ({
|
||||
icon, name, desc = null,
|
||||
option, resetButton = true,
|
||||
enableValue = 1, disableValue = 0,
|
||||
extraOnChange = () => { }, extraOnReset = () => { }, save = true
|
||||
}) => ConfigToggle({
|
||||
icon: icon,
|
||||
name: name,
|
||||
desc: desc,
|
||||
resetButton: resetButton,
|
||||
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);
|
||||
},
|
||||
});
|
||||
|
||||
export const HyprlandSpinButton = ({
|
||||
icon, name, desc = null,
|
||||
option, resetButton = true, save = true,
|
||||
extraOnChange = () => { }, extraOnReset = () => { },
|
||||
...rest
|
||||
}) => ConfigSpinButton({
|
||||
icon: icon,
|
||||
name: name,
|
||||
desc: desc,
|
||||
resetButton: resetButton,
|
||||
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,
|
||||
});
|
||||
|
||||
@@ -9,6 +9,7 @@ import { SystemMessage, ChatMessage } from "./ai_chatmessage.js";
|
||||
import { ConfigToggle, ConfigSegmentedSelection, ConfigGap } from '../../.commonwidgets/configwidgets.js';
|
||||
import { markdownTest } from '../../.miscutils/md2pango.js';
|
||||
import { MarginRevealer } from '../../.widgethacks/advancedrevealers.js';
|
||||
import { AgsToggle } from '../../.commonwidgets/configwidgets_apps.js';
|
||||
|
||||
const MODEL_NAME = `Gemini`;
|
||||
|
||||
@@ -92,33 +93,42 @@ export const GeminiSettings = () => MarginRevealer({
|
||||
hpack: 'center',
|
||||
className: 'sidebar-chat-settings-toggles',
|
||||
children: [
|
||||
ConfigToggle({
|
||||
AgsToggle({
|
||||
icon: 'model_training',
|
||||
name: getString('Prompt'),
|
||||
desc: getString("Tells Gemini:\n- It's a Linux sidebar assistant\n- Be brief and use bullet points"),
|
||||
initValue: GeminiService.assistantPrompt,
|
||||
onChange: (self, newValue) => {
|
||||
option: "ai.enhancements",
|
||||
extraOnChange: (self, newValue) => {
|
||||
GeminiService.assistantPrompt = newValue;
|
||||
},
|
||||
extraOnReset: (self, newValue) => {
|
||||
GeminiService.assistantPrompt = userOptions.ai.enhancements;
|
||||
},
|
||||
}),
|
||||
ConfigToggle({
|
||||
AgsToggle({
|
||||
icon: 'shield',
|
||||
name: getString('Safety'),
|
||||
desc: getString("When turned off, tells the API (not the model) \nto not block harmful/explicit content"),
|
||||
initValue: GeminiService.safe,
|
||||
onChange: (self, newValue) => {
|
||||
option: "ai.safety",
|
||||
extraOnChange: (self, newValue) => {
|
||||
GeminiService.safe = newValue;
|
||||
},
|
||||
extraOnReset: (self, newValue) => {
|
||||
GeminiService.safe = userOptions.ai.safety;
|
||||
},
|
||||
}),
|
||||
ConfigToggle({
|
||||
AgsToggle({
|
||||
icon: 'history',
|
||||
name: getString('History'),
|
||||
desc: getString("Saves chat history\nMessages in previous chats won't show automatically, but they are there"),
|
||||
initValue: GeminiService.useHistory,
|
||||
onChange: (self, newValue) => {
|
||||
option: "ai.useHistory",
|
||||
extraOnChange: (self, newValue) => {
|
||||
GeminiService.useHistory = newValue;
|
||||
},
|
||||
}),
|
||||
extraOnReset: (self, newValue) => {
|
||||
GeminiService.useHistory = userOptions.ai.useHistory;
|
||||
},
|
||||
})
|
||||
]
|
||||
})
|
||||
]
|
||||
|
||||
@@ -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',
|
||||
|
||||
@@ -188,7 +188,7 @@ class GeminiService extends Service {
|
||||
|
||||
get useHistory() { return this._usingHistory; }
|
||||
set useHistory(value) {
|
||||
if (value && !this._usingHistory) this.loadHistory();
|
||||
// if (value && !this._usingHistory) this.loadHistory();
|
||||
this._usingHistory = value;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user