-
-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
1. Themes support 2. Optimization 3. Some fixes
- Loading branch information
Showing
53 changed files
with
586 additions
and
104 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,143 @@ | ||
// by koeqaife ;) | ||
|
||
import { Variable as VariableType } from "types/variable"; | ||
import { MaterialIcon } from "icons"; | ||
import config from "services/configuration"; | ||
import { type ThemeJson } from "variables"; | ||
import { custom_theme } from "variables"; | ||
|
||
const config_version = "1"; | ||
const themes_folder = `${App.configDir}/themes`; | ||
const get_themes_cmd = `python -OOO ${App.configDir}/scripts/themes.py -a ${themes_folder}`; | ||
let _themes = Utils.exec(get_themes_cmd); | ||
const themes: VariableType<ThemeJson[]> = Variable(JSON.parse(_themes)); | ||
const focused: VariableType<ThemeJson | null> = Variable<ThemeJson | null>(null); | ||
|
||
const DEFAULT: ThemeJson = { | ||
name: "Default", | ||
author: "koeqaife", | ||
config_version: "universal", | ||
description: "Hyprland-material-you theme", | ||
hide: false, | ||
load_default_css: true, | ||
path: undefined, | ||
version: "unknown" | ||
}; | ||
const MESSAGES = { | ||
may_not_be_compatible: "This theme may not be compatible with the current version of hyprland-material-you.", | ||
unknown_version: "This theme does not specify ConfigVersion, the theme may not be compatible." | ||
}; | ||
|
||
const theme = (theme: ThemeJson) => | ||
Widget.Button({ | ||
class_name: "row theme", | ||
hexpand: true, | ||
vpack: "start", | ||
setup: (self) => { | ||
if (config.config.current_theme == theme.path) focused.setValue(theme); | ||
self.hook(focused, () => { | ||
self.toggleClassName("focused", focused.value == theme); | ||
}); | ||
}, | ||
on_clicked: () => { | ||
focused.setValue(theme); | ||
}, | ||
child: Widget.Box({ | ||
vertical: true, | ||
hexpand: true, | ||
vpack: "center", | ||
children: [ | ||
Widget.Label({ | ||
hpack: "start", | ||
class_name: "title", | ||
label: theme.name, | ||
truncate: "end" | ||
}), | ||
// @ts-expect-error | ||
Widget.Box({ | ||
children: [ | ||
theme.config_version == "universal" || | ||
(theme.config_version != "0" && theme.config_version == config_version) | ||
? null | ||
: MaterialIcon("error", "18px", { | ||
tooltip_text: | ||
theme.config_version == "0" | ||
? MESSAGES.unknown_version | ||
: MESSAGES.may_not_be_compatible | ||
}), | ||
Widget.Label({ | ||
hpack: "start", | ||
class_name: "description", | ||
label: `${theme.description} (by ${theme.author})`, | ||
truncate: "end" | ||
}) | ||
] | ||
}) | ||
] | ||
}) | ||
}); | ||
|
||
const theme_list = () => { | ||
const reload = () => { | ||
Utils.execAsync(get_themes_cmd).then((out) => { | ||
themes.setValue(JSON.parse(out)); | ||
}); | ||
}; | ||
const _default = theme(DEFAULT); | ||
const box = Widget.Box({ | ||
vertical: true, | ||
children: [_default, ...themes.value.filter((value) => !value.hide).map((value) => theme(value))], | ||
vexpand: true, | ||
attribute: { | ||
reload: reload | ||
}, | ||
setup: (self) => { | ||
self.hook(themes, () => { | ||
box.children = [_default, ...themes.value.filter((value) => !value.hide).map((value) => theme(value))]; | ||
}); | ||
} | ||
}); | ||
return box; | ||
}; | ||
|
||
export const Themes = () => { | ||
const _box = theme_list(); | ||
const _actions = Widget.Box({ | ||
class_name: "actions", | ||
hpack: "end", | ||
spacing: 5, | ||
children: [ | ||
Widget.Button({ | ||
hpack: "end", | ||
class_name: "standard_button", | ||
label: "Reload", | ||
on_clicked: () => { | ||
_box.attribute.reload(); | ||
} | ||
}), | ||
Widget.Button({ | ||
hpack: "end", | ||
class_name: "filled_button", | ||
label: "Select", | ||
on_clicked: () => { | ||
custom_theme.setValue(null); | ||
config.config = { | ||
...config.config, | ||
current_theme: focused.value?.path || null | ||
}; | ||
} | ||
}) | ||
] | ||
}); | ||
const _bottom = Widget.Box({ | ||
hexpand: true, | ||
vertical: true, | ||
class_name: "bottom_bar", | ||
children: [_actions] | ||
}); | ||
return Widget.Box({ | ||
vertical: true, | ||
class_name: "themes", | ||
children: [_box, _bottom] | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,26 @@ | ||
import { Variable as VariableType } from "types/variable"; | ||
// by koeqaife ;) | ||
|
||
export let current_window; | ||
export function set_current_window(value: any) { | ||
current_window = value; | ||
} | ||
|
||
export const current_tab = Variable("network"); | ||
export const saved_networks: VariableType<string[]> = Variable([], { | ||
poll: [ | ||
5000, | ||
() => { | ||
if (current_tab.value != "network" || !current_window?.visible) return saved_networks?.value || []; | ||
const _saved = Utils.exec(`${App.configDir}/scripts/network.sh --saved`); | ||
return _saved.split("\n"); | ||
} | ||
] | ||
export const current_tab = Variable(""); | ||
export const saved_networks = Variable<string[]>([]); | ||
|
||
const _saved_networks = () => { | ||
const _saved = Utils.exec(`${App.configDir}/scripts/network.sh --saved`); | ||
saved_networks.setValue(_saved.split("\n")); | ||
}; | ||
|
||
Utils.interval(10000, () => { | ||
if (current_tab.value == "network" && current_window?.visible) { | ||
_saved_networks(); | ||
} | ||
}); | ||
|
||
current_tab.connect("changed", () => { | ||
if (current_tab.value == "network") { | ||
_saved_networks(); | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
// by koeqaife ;) | ||
|
||
import conf from "services/configuration.ts"; | ||
|
||
const WeatherKey = () => | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
// by koeqaife ;) | ||
|
||
import Gtk from "gi://Gtk?version=3.0"; | ||
|
||
export const RegularWindow = Widget.subclass<typeof Gtk.Window, Gtk.Window.ConstructorProperties>(Gtk.Window); |
Oops, something went wrong.