forked from Shinonome/dots-hyprland
ags: clean up and export handleStyles to command line
This commit is contained in:
@@ -20,7 +20,7 @@ import Overview from './modules/overview/main.js';
|
|||||||
import Session from './modules/session/main.js';
|
import Session from './modules/session/main.js';
|
||||||
import SideLeft from './modules/sideleft/main.js';
|
import SideLeft from './modules/sideleft/main.js';
|
||||||
import SideRight from './modules/sideright/main.js';
|
import SideRight from './modules/sideright/main.js';
|
||||||
import { COMPILED_STYLE_DIR, handleStyles } from './init.js';
|
import { COMPILED_STYLE_DIR } from './init.js';
|
||||||
|
|
||||||
const range = (length, start = 1) => Array.from({ length }, (_, i) => i + start);
|
const range = (length, start = 1) => Array.from({ length }, (_, i) => i + start);
|
||||||
function forMonitors(widget) {
|
function forMonitors(widget) {
|
||||||
@@ -32,7 +32,7 @@ function forMonitorsAsync(widget) {
|
|||||||
return range(n, 0).forEach((n) => widget(n).catch(print))
|
return range(n, 0).forEach((n) => widget(n).catch(print))
|
||||||
}
|
}
|
||||||
|
|
||||||
handleStyles();
|
handleStyles(true);
|
||||||
|
|
||||||
const Windows = () => [
|
const Windows = () => [
|
||||||
// forMonitors(DesktopBackground),
|
// forMonitors(DesktopBackground),
|
||||||
|
|||||||
@@ -8,26 +8,12 @@
|
|||||||
// bind = Super, Tab, exec, ags -t overview
|
// bind = Super, Tab, exec, ags -t overview
|
||||||
|
|
||||||
// Import
|
// Import
|
||||||
import GLib from 'gi://GLib';
|
|
||||||
import App from 'resource:///com/github/Aylur/ags/app.js'
|
import App from 'resource:///com/github/Aylur/ags/app.js'
|
||||||
import * as Utils from 'resource:///com/github/Aylur/ags/utils.js'
|
|
||||||
// Stuff
|
|
||||||
import userOptions from './modules/.configuration/user_options.js';
|
|
||||||
// Widgets
|
// Widgets
|
||||||
import Overview from './modules/overview/main.js';
|
import Overview from './modules/overview/main.js';
|
||||||
|
import { COMPILED_STYLE_DIR } from './init.js';
|
||||||
|
|
||||||
const COMPILED_STYLE_DIR = `${GLib.get_user_cache_dir()}/ags/user/generated`
|
handleStyles(true);
|
||||||
Utils.exec(`mkdir -p "${GLib.get_user_state_dir()}/ags/scss"`);
|
|
||||||
Utils.exec(`bash -c 'echo "" > ${GLib.get_user_state_dir()}/ags/scss/_musicwal.scss'`); // reset music styles
|
|
||||||
Utils.exec(`bash -c 'echo "" > ${GLib.get_user_state_dir()}/ags/scss/_musicmaterial.scss'`); // reset music styles
|
|
||||||
async function applyStyle() {
|
|
||||||
Utils.exec(`mkdir -p ${COMPILED_STYLE_DIR}`);
|
|
||||||
Utils.exec(`sass -I "${GLib.get_user_state_dir()}/ags/scss" -I "${App.configDir}/scss/fallback" "${App.configDir}/scss/main.scss" "${COMPILED_STYLE_DIR}/style.css"`);
|
|
||||||
App.resetCss();
|
|
||||||
App.applyCss(`${COMPILED_STYLE_DIR}/style.css`);
|
|
||||||
console.log('[LOG] Styles loaded')
|
|
||||||
}
|
|
||||||
applyStyle().catch(print);
|
|
||||||
|
|
||||||
App.config({
|
App.config({
|
||||||
css: `${COMPILED_STYLE_DIR}/style.css`,
|
css: `${COMPILED_STYLE_DIR}/style.css`,
|
||||||
@@ -36,4 +22,3 @@ App.config({
|
|||||||
Overview(),
|
Overview(),
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
+9
-7
@@ -4,17 +4,20 @@ import * as Utils from 'resource:///com/github/Aylur/ags/utils.js'
|
|||||||
|
|
||||||
export const COMPILED_STYLE_DIR = `${GLib.get_user_cache_dir()}/ags/user/generated`
|
export const COMPILED_STYLE_DIR = `${GLib.get_user_cache_dir()}/ags/user/generated`
|
||||||
|
|
||||||
export const handleStyles = () => {
|
globalThis['handleStyles'] = (resetMusic) => {
|
||||||
// Reset
|
// Reset
|
||||||
Utils.exec(`mkdir -p "${GLib.get_user_state_dir()}/ags/scss"`);
|
Utils.exec(`mkdir -p "${GLib.get_user_state_dir()}/ags/scss"`);
|
||||||
Utils.exec(`bash -c 'echo "" > ${GLib.get_user_state_dir()}/ags/scss/_musicwal.scss'`); // reset music styles
|
if (resetMusic) {
|
||||||
Utils.exec(`bash -c 'echo "" > ${GLib.get_user_state_dir()}/ags/scss/_musicmaterial.scss'`); // reset music styles
|
Utils.exec(`bash -c 'echo "" > ${GLib.get_user_state_dir()}/ags/scss/_musicwal.scss'`); // reset music styles
|
||||||
|
Utils.exec(`bash -c 'echo "" > ${GLib.get_user_state_dir()}/ags/scss/_musicmaterial.scss'`); // reset music styles
|
||||||
|
}
|
||||||
// Generate overrides
|
// Generate overrides
|
||||||
Utils.writeFile(`
|
Utils.writeFile(
|
||||||
@mixin symbolic-icon {
|
`@mixin symbolic-icon {
|
||||||
-gtk-icon-theme: '${userOptions.icons.symbolicIconTheme}';
|
-gtk-icon-theme: '${userOptions.icons.symbolicIconTheme}';
|
||||||
}
|
}
|
||||||
`, `${GLib.get_user_state_dir()}/ags/scss/_lib_mixins_overrides.scss`)
|
`,
|
||||||
|
`${GLib.get_user_state_dir()}/ags/scss/_lib_mixins_overrides.scss`)
|
||||||
// Compile and apply
|
// Compile and apply
|
||||||
async function applyStyle() {
|
async function applyStyle() {
|
||||||
Utils.exec(`mkdir -p ${COMPILED_STYLE_DIR}`);
|
Utils.exec(`mkdir -p ${COMPILED_STYLE_DIR}`);
|
||||||
@@ -25,4 +28,3 @@ export const handleStyles = () => {
|
|||||||
}
|
}
|
||||||
applyStyle().catch(print);
|
applyStyle().catch(print);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -150,9 +150,8 @@ apply_gtk() { # Using gradience-cli
|
|||||||
}
|
}
|
||||||
|
|
||||||
apply_ags() {
|
apply_ags() {
|
||||||
sass -I "$STATE_DIR/scss" -I "$CONFIG_DIR/scss/fallback" "$CONFIG_DIR"/scss/main.scss "$CACHE_DIR"/user/generated/style.css
|
ags run-js "handleStyles(false);"
|
||||||
ags run-js 'openColorScheme.value = true; Utils.timeout(2000, () => openColorScheme.value = false);'
|
ags run-js 'openColorScheme.value = true; Utils.timeout(2000, () => openColorScheme.value = false);'
|
||||||
ags run-js "App.resetCss(); App.applyCss('${CACHE_DIR}/user/generated/style.css');"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if [[ "$1" = "--bad-apple" ]]; then
|
if [[ "$1" = "--bad-apple" ]]; then
|
||||||
|
|||||||
Reference in New Issue
Block a user