forked from Shinonome/dots-hyprland
base configs
This commit is contained in:
@@ -86,20 +86,14 @@ export const BluetoothIndicator = () => Widget.Stack({
|
||||
transition: 'slide_up_down',
|
||||
transitionDuration: userOptions.animations.durationSmall,
|
||||
children: {
|
||||
'disabled': Widget.Label({ className: 'txt-norm icon-material', label: 'bluetooth_disabled' }),
|
||||
'enabled': Widget.Label({ className: 'txt-norm icon-material', label: 'bluetooth' }),
|
||||
'connected': Widget.Label({ className: 'txt-norm icon-material', label: 'bluetooth_connected' }),
|
||||
'false': Widget.Label({ className: 'txt-norm icon-material', label: 'bluetooth_disabled' }),
|
||||
'true': Widget.Label({ className: 'txt-norm icon-material', label: 'bluetooth' }),
|
||||
},
|
||||
setup: (self) =>
|
||||
self.hook(Bluetooth, (stack) => {
|
||||
if (!Bluetooth.enabled) {
|
||||
stack.shown = 'disabled';
|
||||
} else if (Bluetooth.connected_devices.length === 0) {
|
||||
stack.shown = 'enabled';
|
||||
} else if (Bluetooth.connected_devices.length > 0) {
|
||||
stack.shown = 'connected';
|
||||
}
|
||||
}),
|
||||
setup: (self) => self
|
||||
.hook(Bluetooth, stack => {
|
||||
stack.shown = String(Bluetooth.enabled);
|
||||
})
|
||||
,
|
||||
});
|
||||
|
||||
const BluetoothDevices = () => Widget.Box({
|
||||
@@ -164,11 +158,8 @@ const NetworkWifiIndicator = () => Widget.Stack({
|
||||
transition: 'slide_up_down',
|
||||
transitionDuration: userOptions.animations.durationSmall,
|
||||
children: {
|
||||
'disabled': Widget.Label({ className: 'txt-norm icon-material', label: 'signal_wifi_off' }),
|
||||
'disconnected': Widget.Label({
|
||||
className: 'txt-norm icon-material',
|
||||
label: 'signal_wifi_statusbar_not_connected',
|
||||
}),
|
||||
'disabled': Widget.Label({ className: 'txt-norm icon-material', label: 'wifi_off' }),
|
||||
'disconnected': Widget.Label({ className: 'txt-norm icon-material', label: 'signal_wifi_off' }),
|
||||
'connecting': Widget.Label({ className: 'txt-norm icon-material', label: 'settings_ethernet' }),
|
||||
'0': Widget.Label({ className: 'txt-norm icon-material', label: 'signal_wifi_0_bar' }),
|
||||
'1': Widget.Label({ className: 'txt-norm icon-material', label: 'network_wifi_1_bar' }),
|
||||
@@ -180,11 +171,10 @@ const NetworkWifiIndicator = () => Widget.Stack({
|
||||
if (!Network.wifi) {
|
||||
return;
|
||||
}
|
||||
if (!Network.wifi.enabled) {
|
||||
stack.shown = 'disabled';
|
||||
} else if (Network.wifi.internet == 'connected') {
|
||||
if (Network.wifi.internet == 'connected') {
|
||||
stack.shown = String(Math.ceil(Network.wifi.strength / 25));
|
||||
} else if (['disconnected', 'connecting'].includes(Network.wifi.internet)) {
|
||||
}
|
||||
else if (["disconnected", "connecting"].includes(Network.wifi.internet)) {
|
||||
stack.shown = Network.wifi.internet;
|
||||
}
|
||||
}),
|
||||
|
||||
@@ -60,13 +60,6 @@ export default (overviewMonitor = 0) => {
|
||||
else if (x < 0) { w = x + w; x = 0; }
|
||||
if (y + h <= 0) x += (Math.floor(y / monitors[monitor].height) * monitors[monitor].height);
|
||||
else if (y < 0) { h = y + h; y = 0; }
|
||||
<<<<<<< HEAD
|
||||
// Prevents throwing an error when multiple monitors are plugged in but only one is enabled (#1047)
|
||||
=======
|
||||
>>>>>>> 1996008 (heda fix)
|
||||
if (monitors.length - 1 < monitor) {
|
||||
monitor = monitors.length - 1;
|
||||
}
|
||||
// Truncate if offscreen
|
||||
if (x + w > monitors[monitor].width) w = monitors[monitor].width - x;
|
||||
if (y + h > monitors[monitor].height) h = monitors[monitor].height - y;
|
||||
|
||||
@@ -1,307 +1,130 @@
|
||||
const { GLib } = imports.gi;
|
||||
import Hyprland from "resource:///com/github/Aylur/ags/service/hyprland.js";
|
||||
import Widget from "resource:///com/github/Aylur/ags/widget.js";
|
||||
import * as Utils from "resource:///com/github/Aylur/ags/utils.js";
|
||||
import Hyprland from 'resource:///com/github/Aylur/ags/service/hyprland.js';
|
||||
import Widget from 'resource:///com/github/Aylur/ags/widget.js';
|
||||
import * as Utils from 'resource:///com/github/Aylur/ags/utils.js';
|
||||
const { Box, Button, Icon, Label, Scrollable, Slider, Stack } = 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 { MaterialIcon } from '../../.commonwidgets/materialicon.js';
|
||||
import { setupCursorHover } from '../../.widgetutils/cursorhover.js';
|
||||
import { ConfigGap, ConfigSpinButton, ConfigToggle } from '../../.commonwidgets/configwidgets.js';
|
||||
|
||||
// Hyprland config file path
|
||||
const configFile = GLib.get_home_dir() + "/.config/hypr/hyprland/HyprAGS.conf";
|
||||
|
||||
// Ensure the config file exists
|
||||
function ensureConfigFileExists() {
|
||||
if (!GLib.file_test(configFile, GLib.FileTest.EXISTS)) {
|
||||
execAsync(["touch", configFile]).catch((err) =>
|
||||
logError("Error creating config file", err),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// Helper to update the config file
|
||||
function updateConfig(option, value) {
|
||||
execAsync([
|
||||
"bash",
|
||||
"-c",
|
||||
`
|
||||
if grep -q "^${option} =" ${configFile}; then
|
||||
sed -i "s/^${option} = .*/${option} = ${value}/" ${configFile}
|
||||
else
|
||||
echo "${option} = ${value}" >> ${configFile}
|
||||
fi
|
||||
`,
|
||||
]).catch((err) => logError("Failed to update config", err));
|
||||
}
|
||||
|
||||
// Toggles for Hyprland settings
|
||||
const HyprlandToggle = ({
|
||||
icon,
|
||||
name,
|
||||
desc = null,
|
||||
option,
|
||||
enableValue = 1,
|
||||
disableValue = 0,
|
||||
extraOnChange = () => {},
|
||||
}) =>
|
||||
ConfigToggle({
|
||||
const HyprlandToggle = ({ icon, name, desc = null, option, enableValue = 1, disableValue = 0, extraOnChange = () => { } }) => ConfigToggle({
|
||||
icon: icon,
|
||||
name: name,
|
||||
desc: desc,
|
||||
initValue: JSON.parse(exec(`hyprctl getoption -j ${option}`))["int"] != 0,
|
||||
onChange: (self, newValue) => {
|
||||
execAsync([
|
||||
"hyprctl",
|
||||
"keyword",
|
||||
option,
|
||||
`${newValue ? enableValue : disableValue}`,
|
||||
])
|
||||
.then(() => {
|
||||
updateConfig(option, newValue ? enableValue : disableValue);
|
||||
extraOnChange(self, newValue);
|
||||
})
|
||||
.catch((err) => logError("Error applying change", err));
|
||||
},
|
||||
});
|
||||
execAsync(['hyprctl', 'keyword', option, `${newValue ? enableValue : disableValue}`]).catch(print);
|
||||
extraOnChange(self, newValue);
|
||||
}
|
||||
});
|
||||
|
||||
// SpinButton for numeric settings
|
||||
const HyprlandSpinButton = ({ icon, name, desc = null, option, ...rest }) =>
|
||||
ConfigSpinButton({
|
||||
const HyprlandSpinButton = ({ icon, name, desc = null, option, ...rest }) => ConfigSpinButton({
|
||||
icon: icon,
|
||||
name: name,
|
||||
desc: desc,
|
||||
initValue: Number(
|
||||
JSON.parse(exec(`hyprctl getoption -j ${option}`))["int"],
|
||||
),
|
||||
initValue: Number(JSON.parse(exec(`hyprctl getoption -j ${option}`))["int"]),
|
||||
onChange: (self, newValue) => {
|
||||
execAsync(["hyprctl", "keyword", option, `${newValue}`])
|
||||
.then(() => {
|
||||
updateConfig(option, newValue);
|
||||
})
|
||||
.catch((err) => logError("Error applying change", err));
|
||||
execAsync(['hyprctl', 'keyword', option, `${newValue}`]).catch(print);
|
||||
},
|
||||
...rest,
|
||||
});
|
||||
});
|
||||
|
||||
const Subcategory = (children) =>
|
||||
Box({
|
||||
className: "margin-left-20",
|
||||
const Subcategory = (children) => Box({
|
||||
className: 'margin-left-20',
|
||||
vertical: true,
|
||||
children: children,
|
||||
});
|
||||
})
|
||||
|
||||
export default (props) => {
|
||||
const ConfigSection = ({ name, children }) =>
|
||||
Box({
|
||||
vertical: true,
|
||||
className: "spacing-v-5",
|
||||
children: [
|
||||
Label({
|
||||
hpack: "center",
|
||||
className: "txt txt-large margin-left-10",
|
||||
label: name,
|
||||
}),
|
||||
Box({
|
||||
className: "margin-left-10 margin-right-10",
|
||||
vertical: true,
|
||||
children: children,
|
||||
}),
|
||||
],
|
||||
const ConfigSection = ({ name, children }) => Box({
|
||||
vertical: true,
|
||||
className: 'spacing-v-5',
|
||||
children: [
|
||||
Label({
|
||||
hpack: 'center',
|
||||
className: 'txt txt-large margin-left-10',
|
||||
label: name,
|
||||
}),
|
||||
Box({
|
||||
className: 'margin-left-10 margin-right-10',
|
||||
vertical: true,
|
||||
children: children,
|
||||
})
|
||||
]
|
||||
})
|
||||
const mainContent = Scrollable({
|
||||
vexpand: true,
|
||||
child: Box({
|
||||
vertical: true,
|
||||
className: 'spacing-v-10',
|
||||
children: [
|
||||
ConfigSection({
|
||||
name: getString('Effects'), children: [
|
||||
ConfigToggle({
|
||||
icon: 'border_clear',
|
||||
name: getString('Transparency'),
|
||||
desc: getString('[AGS]\nMake shell elements transparent\nBlur is also recommended if you enable this'),
|
||||
initValue: exec(`bash -c "sed -n \'2p\' ${GLib.get_user_state_dir()}/ags/user/colormode.txt"`) == "transparent",
|
||||
onChange: (self, newValue) => {
|
||||
const transparency = newValue == 0 ? "opaque" : "transparent";
|
||||
console.log(transparency);
|
||||
execAsync([`bash`, `-c`, `mkdir -p ${GLib.get_user_state_dir()}/ags/user && sed -i "2s/.*/${transparency}/" ${GLib.get_user_state_dir()}/ags/user/colormode.txt`])
|
||||
.then(execAsync(['bash', '-c', `${App.configDir}/scripts/color_generation/switchcolor.sh`]))
|
||||
.catch(print);
|
||||
},
|
||||
}),
|
||||
HyprlandToggle({ icon: 'blur_on', name: getString('Blur'), desc: getString("[Hyprland]\nEnable blur on transparent elements\nDoesn't affect performance/power consumption unless you have transparent windows."), option: "decoration:blur:enabled" }),
|
||||
Subcategory([
|
||||
HyprlandToggle({ icon: 'stack_off', name: getString('X-ray'), desc: getString("[Hyprland]\nMake everything behind a window/layer except the wallpaper not rendered on its blurred surface\nRecommended to improve performance (if you don't abuse transparency/blur) "), option: "decoration:blur:xray" }),
|
||||
HyprlandSpinButton({ icon: 'target', name: getString('Size'), desc: getString('[Hyprland]\nAdjust the blur radius. Generally doesn\'t affect performance\nHigher = more color spread'), option: 'decoration:blur:size', minValue: 1, maxValue: 1000 }),
|
||||
HyprlandSpinButton({ icon: 'repeat', name: getString('Passes'), desc: getString('[Hyprland] Adjust the number of runs of the blur algorithm\nMore passes = more spread and power consumption\n4 is recommended\n2- would look weird and 6+ would look lame.'), option: 'decoration:blur:passes', minValue: 1, maxValue: 10 }),
|
||||
]),
|
||||
ConfigGap({}),
|
||||
HyprlandToggle({
|
||||
icon: 'animation', name: getString('Animations'), desc: getString('[Hyprland] [GTK]\nEnable animations'), option: 'animations:enabled',
|
||||
extraOnChange: (self, newValue) => execAsync(['gsettings', 'set', 'org.gnome.desktop.interface', 'enable-animations', `${newValue}`])
|
||||
}),
|
||||
Subcategory([
|
||||
ConfigSpinButton({
|
||||
icon: 'clear_all',
|
||||
name: getString('Choreography delay'),
|
||||
desc: getString('In milliseconds, the delay between animations of a series'),
|
||||
initValue: userOptions.animations.choreographyDelay,
|
||||
step: 10, minValue: 0, maxValue: 1000,
|
||||
onChange: (self, newValue) => {
|
||||
userOptions.animations.choreographyDelay = newValue
|
||||
},
|
||||
})
|
||||
]),
|
||||
]
|
||||
}),
|
||||
ConfigSection({
|
||||
name: getString('Developer'), children: [
|
||||
HyprlandToggle({ icon: 'speed', name: getString('Show FPS'), desc: getString("[Hyprland]\nShow FPS overlay on top-left corner"), option: "debug:overlay" }),
|
||||
HyprlandToggle({ icon: 'sort', name: getString('Log to stdout'), desc: getString("[Hyprland]\nPrint LOG, ERR, WARN, etc. messages to the console"), option: "debug:enable_stdout_logs" }),
|
||||
HyprlandToggle({ icon: 'motion_sensor_active', name: getString('Damage tracking'), desc: getString("[Hyprland]\nEnable damage tracking\nGenerally, leave it on.\nTurn off only when a shader doesn't work"), option: "debug:damage_tracking", enableValue: 2 }),
|
||||
HyprlandToggle({ icon: 'destruction', name: getString('Damage blink'), desc: getString("[Hyprland] [Epilepsy warning!]\nShow screen damage flashes"), option: "debug:damage_blink" }),
|
||||
]
|
||||
}),
|
||||
]
|
||||
})
|
||||
});
|
||||
|
||||
const mainContent = Scrollable({
|
||||
vexpand: true,
|
||||
child: Box({
|
||||
vertical: true,
|
||||
className: "spacing-v-10",
|
||||
children: [
|
||||
// Roundings Section
|
||||
ConfigSection({
|
||||
name: getString("Window"),
|
||||
children: [
|
||||
HyprlandSpinButton({
|
||||
icon: "crop_square",
|
||||
name: getString("Window Roundings"),
|
||||
desc: getString(
|
||||
"[Hyprland]\nAdjust the window corner roundings.",
|
||||
),
|
||||
option: "decoration:rounding",
|
||||
minValue: 0,
|
||||
maxValue: 50,
|
||||
step: 1,
|
||||
onChange: (self, newValue) => {
|
||||
updateConfig("decoration:rounding", newValue);
|
||||
},
|
||||
}),
|
||||
],
|
||||
}),
|
||||
// Effects Section
|
||||
ConfigSection({
|
||||
name: getString("Effects"),
|
||||
children: [
|
||||
ConfigToggle({
|
||||
icon: "border_clear",
|
||||
name: getString("Transparency"),
|
||||
desc: getString(
|
||||
"[AGS]\nMake shell elements transparent\nBlur is also recommended if you enable this",
|
||||
),
|
||||
initValue:
|
||||
exec(
|
||||
`bash -c "sed -n '2p' ${GLib.get_user_state_dir()}/ags/user/colormode.txt"`,
|
||||
) == "transparent",
|
||||
onChange: (self, newValue) => {
|
||||
const transparency = newValue == 0 ? "opaque" : "transparent";
|
||||
execAsync([
|
||||
`bash`,
|
||||
`-c`,
|
||||
`mkdir -p ${GLib.get_user_state_dir()}/ags/user && sed -i "2s/.*/${transparency}/" ${GLib.get_user_state_dir()}/ags/user/colormode.txt`,
|
||||
])
|
||||
.then(
|
||||
execAsync([
|
||||
"bash",
|
||||
"-c",
|
||||
`${App.configDir}/scripts/color_generation/switchcolor.sh`,
|
||||
]),
|
||||
)
|
||||
.then(() => {
|
||||
if (newValue) {
|
||||
updateConfig("decoration:active_opacity", 0.85);
|
||||
updateConfig("decoration:inactive_opacity", 0.85);
|
||||
} else {
|
||||
updateConfig("decoration:active_opacity", 1);
|
||||
updateConfig("decoration:inactive_opacity", 1);
|
||||
}
|
||||
})
|
||||
.catch(print);
|
||||
},
|
||||
}),
|
||||
HyprlandToggle({
|
||||
icon: "blur_on",
|
||||
name: getString("Blur"),
|
||||
desc: getString(
|
||||
"[Hyprland]\nEnable blur on transparent elements.",
|
||||
),
|
||||
option: "decoration:blur:enabled",
|
||||
}),
|
||||
Subcategory([
|
||||
HyprlandSpinButton({
|
||||
icon: "target",
|
||||
name: getString("Blur Size"),
|
||||
desc: getString("[Hyprland]\nAdjust the blur radius."),
|
||||
option: "decoration:blur:size",
|
||||
minValue: 1,
|
||||
maxValue: 1000,
|
||||
}),
|
||||
HyprlandSpinButton({
|
||||
icon: "repeat",
|
||||
name: getString("Blur Passes"),
|
||||
desc: getString(
|
||||
"[Hyprland]\nAdjust the number of passes for blur.",
|
||||
),
|
||||
option: "decoration:blur:passes",
|
||||
minValue: 1,
|
||||
maxValue: 10,
|
||||
}),
|
||||
]),
|
||||
HyprlandToggle({
|
||||
icon: "auto_fix_high",
|
||||
name: getString("Blur Special"),
|
||||
desc: getString("[Hyprland]\nEnable special blur effects."),
|
||||
option: "decoration:blur:special",
|
||||
}),
|
||||
ConfigGap({}),
|
||||
HyprlandToggle({
|
||||
icon: "animation",
|
||||
name: getString("Animations"),
|
||||
desc: getString("[Hyprland] [GTK]\nEnable animations"),
|
||||
option: "animations:enabled",
|
||||
extraOnChange: (self, newValue) =>
|
||||
execAsync([
|
||||
"gsettings",
|
||||
"set",
|
||||
"org.gnome.desktop.interface",
|
||||
"enable-animations",
|
||||
`${newValue}`,
|
||||
]),
|
||||
}),
|
||||
Subcategory([
|
||||
ConfigSpinButton({
|
||||
icon: "clear_all",
|
||||
name: getString("Choreography delay"),
|
||||
desc: getString(
|
||||
"In milliseconds, the delay between animations of a series",
|
||||
),
|
||||
initValue: userOptions.animations.choreographyDelay,
|
||||
step: 10,
|
||||
minValue: 0,
|
||||
maxValue: 1000,
|
||||
onChange: (self, newValue) => {
|
||||
userOptions.animations.choreographyDelay = newValue;
|
||||
},
|
||||
}),
|
||||
]),
|
||||
],
|
||||
}),
|
||||
// Developer Section
|
||||
ConfigSection({
|
||||
name: getString("Developer"),
|
||||
children: [
|
||||
HyprlandToggle({
|
||||
icon: "speed",
|
||||
name: getString("Show FPS"),
|
||||
desc: getString(
|
||||
"[Hyprland]\nShow FPS overlay on top-left corner.",
|
||||
),
|
||||
option: "debug:overlay",
|
||||
}),
|
||||
HyprlandToggle({
|
||||
icon: "sort",
|
||||
name: getString("Log to stdout"),
|
||||
desc: getString("[Hyprland]\nPrint log messages to console."),
|
||||
option: "debug:enable_stdout_logs",
|
||||
}),
|
||||
HyprlandToggle({
|
||||
icon: "motion_sensor_active",
|
||||
name: getString("Damage Tracking"),
|
||||
desc: getString("[Hyprland]\nEnable damage tracking."),
|
||||
option: "debug:damage_tracking",
|
||||
enableValue: 2,
|
||||
}),
|
||||
HyprlandToggle({
|
||||
icon: "destruction",
|
||||
name: getString("Damage Blink"),
|
||||
desc: getString("[Hyprland]\nShow screen damage flashes."),
|
||||
option: "debug:damage_blink",
|
||||
}),
|
||||
],
|
||||
}),
|
||||
],
|
||||
}),
|
||||
});
|
||||
|
||||
const footNote = Box({
|
||||
homogeneous: true,
|
||||
children: [
|
||||
Label({
|
||||
hpack: "center",
|
||||
className: "txt txt-italic txt-subtext margin-5",
|
||||
label: getString("Not all changes are saved"),
|
||||
}),
|
||||
],
|
||||
});
|
||||
|
||||
return Box({
|
||||
...props,
|
||||
className: "spacing-v-5",
|
||||
vertical: true,
|
||||
children: [mainContent, footNote],
|
||||
});
|
||||
};
|
||||
|
||||
// Ensure the config file exists before applying changes
|
||||
ensureConfigFileExists();
|
||||
const footNote = Box({
|
||||
homogeneous: true,
|
||||
children: [Label({
|
||||
hpack: 'center',
|
||||
className: 'txt txt-italic txt-subtext margin-5',
|
||||
label: getString('Not all changes are saved'),
|
||||
})]
|
||||
})
|
||||
return Box({
|
||||
...props,
|
||||
className: 'spacing-v-5',
|
||||
vertical: true,
|
||||
children: [
|
||||
mainContent,
|
||||
footNote,
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user