mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-01-29 07:52:50 -05:00
matugen: opt to run user templates
This commit is contained in:
@@ -33,6 +33,7 @@ Singleton {
|
|||||||
property string currentThemeName: "blue"
|
property string currentThemeName: "blue"
|
||||||
property string customThemeFile: ""
|
property string customThemeFile: ""
|
||||||
property string matugenScheme: "scheme-tonal-spot"
|
property string matugenScheme: "scheme-tonal-spot"
|
||||||
|
property bool runUserMatugenTemplates: true
|
||||||
property real dankBarTransparency: 1.0
|
property real dankBarTransparency: 1.0
|
||||||
property real dankBarWidgetTransparency: 1.0
|
property real dankBarWidgetTransparency: 1.0
|
||||||
property real popupTransparency: 1.0
|
property real popupTransparency: 1.0
|
||||||
@@ -283,6 +284,7 @@ Singleton {
|
|||||||
}
|
}
|
||||||
customThemeFile = settings.customThemeFile !== undefined ? settings.customThemeFile : ""
|
customThemeFile = settings.customThemeFile !== undefined ? settings.customThemeFile : ""
|
||||||
matugenScheme = settings.matugenScheme !== undefined ? settings.matugenScheme : "scheme-tonal-spot"
|
matugenScheme = settings.matugenScheme !== undefined ? settings.matugenScheme : "scheme-tonal-spot"
|
||||||
|
runUserMatugenTemplates = settings.runUserMatugenTemplates !== undefined ? settings.runUserMatugenTemplates : true
|
||||||
dankBarTransparency = settings.dankBarTransparency !== undefined ? (settings.dankBarTransparency > 1 ? settings.dankBarTransparency / 100 : settings.dankBarTransparency) : (settings.topBarTransparency !== undefined ? (settings.topBarTransparency > 1 ? settings.topBarTransparency / 100 : settings.topBarTransparency) : 1.0)
|
dankBarTransparency = settings.dankBarTransparency !== undefined ? (settings.dankBarTransparency > 1 ? settings.dankBarTransparency / 100 : settings.dankBarTransparency) : (settings.topBarTransparency !== undefined ? (settings.topBarTransparency > 1 ? settings.topBarTransparency / 100 : settings.topBarTransparency) : 1.0)
|
||||||
dankBarWidgetTransparency = settings.dankBarWidgetTransparency !== undefined ? (settings.dankBarWidgetTransparency > 1 ? settings.dankBarWidgetTransparency / 100 : settings.dankBarWidgetTransparency) : (settings.topBarWidgetTransparency !== undefined ? (settings.topBarWidgetTransparency > 1 ? settings.topBarWidgetTransparency / 100 : settings.topBarWidgetTransparency) : 1.0)
|
dankBarWidgetTransparency = settings.dankBarWidgetTransparency !== undefined ? (settings.dankBarWidgetTransparency > 1 ? settings.dankBarWidgetTransparency / 100 : settings.dankBarWidgetTransparency) : (settings.topBarWidgetTransparency !== undefined ? (settings.topBarWidgetTransparency > 1 ? settings.topBarWidgetTransparency / 100 : settings.topBarWidgetTransparency) : 1.0)
|
||||||
popupTransparency = settings.popupTransparency !== undefined ? (settings.popupTransparency > 1 ? settings.popupTransparency / 100 : settings.popupTransparency) : 1.0
|
popupTransparency = settings.popupTransparency !== undefined ? (settings.popupTransparency > 1 ? settings.popupTransparency / 100 : settings.popupTransparency) : 1.0
|
||||||
@@ -452,6 +454,7 @@ Singleton {
|
|||||||
"currentThemeName": currentThemeName,
|
"currentThemeName": currentThemeName,
|
||||||
"customThemeFile": customThemeFile,
|
"customThemeFile": customThemeFile,
|
||||||
"matugenScheme": matugenScheme,
|
"matugenScheme": matugenScheme,
|
||||||
|
"runUserMatugenTemplates": runUserMatugenTemplates,
|
||||||
"dankBarTransparency": dankBarTransparency,
|
"dankBarTransparency": dankBarTransparency,
|
||||||
"dankBarWidgetTransparency": dankBarWidgetTransparency,
|
"dankBarWidgetTransparency": dankBarWidgetTransparency,
|
||||||
"popupTransparency": popupTransparency,
|
"popupTransparency": popupTransparency,
|
||||||
@@ -711,6 +714,18 @@ Singleton {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function setRunUserMatugenTemplates(enabled) {
|
||||||
|
if (runUserMatugenTemplates === enabled)
|
||||||
|
return
|
||||||
|
|
||||||
|
runUserMatugenTemplates = enabled
|
||||||
|
saveSettings()
|
||||||
|
|
||||||
|
if (typeof Theme !== "undefined") {
|
||||||
|
Theme.generateSystemThemesFromCurrentTheme()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function setDankBarTransparency(transparency) {
|
function setDankBarTransparency(transparency) {
|
||||||
dankBarTransparency = transparency
|
dankBarTransparency = transparency
|
||||||
saveSettings()
|
saveSettings()
|
||||||
|
|||||||
@@ -596,7 +596,8 @@ Singleton {
|
|||||||
"mode": isLight ? "light" : "dark",
|
"mode": isLight ? "light" : "dark",
|
||||||
"iconTheme": iconTheme || "System Default",
|
"iconTheme": iconTheme || "System Default",
|
||||||
"matugenType": matugenType || "scheme-tonal-spot",
|
"matugenType": matugenType || "scheme-tonal-spot",
|
||||||
"surfaceBase": (typeof SettingsData !== "undefined" && SettingsData.surfaceBase) ? SettingsData.surfaceBase : "sc"
|
"surfaceBase": (typeof SettingsData !== "undefined" && SettingsData.surfaceBase) ? SettingsData.surfaceBase : "sc",
|
||||||
|
"runUserTemplates": (typeof SettingsData !== "undefined") ? SettingsData.runUserMatugenTemplates : true
|
||||||
}
|
}
|
||||||
|
|
||||||
const json = JSON.stringify(desired)
|
const json = JSON.stringify(desired)
|
||||||
|
|||||||
@@ -998,6 +998,56 @@ Item {
|
|||||||
width: parent.width
|
width: parent.width
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Rectangle {
|
||||||
|
width: parent.width
|
||||||
|
height: 1
|
||||||
|
color: Theme.outline
|
||||||
|
opacity: 0.2
|
||||||
|
}
|
||||||
|
|
||||||
|
Row {
|
||||||
|
width: parent.width
|
||||||
|
spacing: Theme.spacingM
|
||||||
|
|
||||||
|
DankIcon {
|
||||||
|
name: "code"
|
||||||
|
size: Theme.iconSize
|
||||||
|
color: SettingsData.runUserMatugenTemplates ? Theme.primary : Theme.surfaceVariantText
|
||||||
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
|
}
|
||||||
|
|
||||||
|
Column {
|
||||||
|
width: parent.width - Theme.iconSize - Theme.spacingM - runUserTemplatesToggle.width - Theme.spacingM
|
||||||
|
spacing: Theme.spacingXS
|
||||||
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
|
|
||||||
|
StyledText {
|
||||||
|
text: I18n.tr("Run User Templates")
|
||||||
|
font.pixelSize: Theme.fontSizeLarge
|
||||||
|
font.weight: Font.Medium
|
||||||
|
color: Theme.surfaceText
|
||||||
|
}
|
||||||
|
|
||||||
|
StyledText {
|
||||||
|
text: I18n.tr("Execute templates from ~/.config/matugen/config.toml")
|
||||||
|
font.pixelSize: Theme.fontSizeSmall
|
||||||
|
color: Theme.surfaceVariantText
|
||||||
|
width: parent.width
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
DankToggle {
|
||||||
|
id: runUserTemplatesToggle
|
||||||
|
|
||||||
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
|
checked: SettingsData.runUserMatugenTemplates
|
||||||
|
enabled: Theme.matugenAvailable
|
||||||
|
onToggled: checked => {
|
||||||
|
SettingsData.setRunUserMatugenTemplates(checked)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
StyledText {
|
StyledText {
|
||||||
text: I18n.tr("matugen not detected - dynamic theming unavailable")
|
text: I18n.tr("matugen not detected - dynamic theming unavailable")
|
||||||
font.pixelSize: Theme.fontSizeSmall
|
font.pixelSize: Theme.fontSizeSmall
|
||||||
@@ -1085,6 +1135,7 @@ Item {
|
|||||||
}
|
}
|
||||||
|
|
||||||
DankDropdown {
|
DankDropdown {
|
||||||
|
width: parent.width
|
||||||
text: I18n.tr("Temperature")
|
text: I18n.tr("Temperature")
|
||||||
description: I18n.tr("Color temperature for night mode")
|
description: I18n.tr("Color temperature for night mode")
|
||||||
currentValue: SessionData.nightModeTemperature + "K"
|
currentValue: SessionData.nightModeTemperature + "K"
|
||||||
|
|||||||
@@ -54,24 +54,28 @@ key_of() {
|
|||||||
local icon=$(echo "$json" | sed 's/.*"iconTheme": *"\([^"]*\)".*/\1/')
|
local icon=$(echo "$json" | sed 's/.*"iconTheme": *"\([^"]*\)".*/\1/')
|
||||||
local matugen_type=$(echo "$json" | sed 's/.*"matugenType": *"\([^"]*\)".*/\1/')
|
local matugen_type=$(echo "$json" | sed 's/.*"matugenType": *"\([^"]*\)".*/\1/')
|
||||||
local surface_base=$(echo "$json" | sed 's/.*"surfaceBase": *"\([^"]*\)".*/\1/')
|
local surface_base=$(echo "$json" | sed 's/.*"surfaceBase": *"\([^"]*\)".*/\1/')
|
||||||
|
local run_user_templates=$(echo "$json" | sed 's/.*"runUserTemplates": *\([^,}]*\).*/\1/')
|
||||||
[[ -z "$icon" ]] && icon="System Default"
|
[[ -z "$icon" ]] && icon="System Default"
|
||||||
[[ -z "$matugen_type" ]] && matugen_type="scheme-tonal-spot"
|
[[ -z "$matugen_type" ]] && matugen_type="scheme-tonal-spot"
|
||||||
[[ -z "$surface_base" ]] && surface_base="sc"
|
[[ -z "$surface_base" ]] && surface_base="sc"
|
||||||
echo "${kind}|${value}|${mode}|${icon}|${matugen_type}|${surface_base}" | sha256sum | cut -d' ' -f1
|
[[ -z "$run_user_templates" ]] && run_user_templates="true"
|
||||||
|
echo "${kind}|${value}|${mode}|${icon}|${matugen_type}|${surface_base}|${run_user_templates}" | sha256sum | cut -d' ' -f1
|
||||||
}
|
}
|
||||||
|
|
||||||
build_once() {
|
build_once() {
|
||||||
local json="$1"
|
local json="$1"
|
||||||
local kind value mode icon matugen_type surface_base
|
local kind value mode icon matugen_type surface_base run_user_templates
|
||||||
kind=$(echo "$json" | sed 's/.*"kind": *"\([^"]*\)".*/\1/')
|
kind=$(echo "$json" | sed 's/.*"kind": *"\([^"]*\)".*/\1/')
|
||||||
value=$(echo "$json" | sed 's/.*"value": *"\([^"]*\)".*/\1/')
|
value=$(echo "$json" | sed 's/.*"value": *"\([^"]*\)".*/\1/')
|
||||||
mode=$(echo "$json" | sed 's/.*"mode": *"\([^"]*\)".*/\1/')
|
mode=$(echo "$json" | sed 's/.*"mode": *"\([^"]*\)".*/\1/')
|
||||||
icon=$(echo "$json" | sed 's/.*"iconTheme": *"\([^"]*\)".*/\1/')
|
icon=$(echo "$json" | sed 's/.*"iconTheme": *"\([^"]*\)".*/\1/')
|
||||||
matugen_type=$(echo "$json" | sed 's/.*"matugenType": *"\([^"]*\)".*/\1/')
|
matugen_type=$(echo "$json" | sed 's/.*"matugenType": *"\([^"]*\)".*/\1/')
|
||||||
surface_base=$(echo "$json" | sed 's/.*"surfaceBase": *"\([^"]*\)".*/\1/')
|
surface_base=$(echo "$json" | sed 's/.*"surfaceBase": *"\([^"]*\)".*/\1/')
|
||||||
|
run_user_templates=$(echo "$json" | sed 's/.*"runUserTemplates": *\([^,}]*\).*/\1/')
|
||||||
[[ -z "$icon" ]] && icon="System Default"
|
[[ -z "$icon" ]] && icon="System Default"
|
||||||
[[ -z "$matugen_type" ]] && matugen_type="scheme-tonal-spot"
|
[[ -z "$matugen_type" ]] && matugen_type="scheme-tonal-spot"
|
||||||
[[ -z "$surface_base" ]] && surface_base="sc"
|
[[ -z "$surface_base" ]] && surface_base="sc"
|
||||||
|
[[ -z "$run_user_templates" ]] && run_user_templates="true"
|
||||||
|
|
||||||
USER_MATUGEN_DIR="$CONFIG_DIR/matugen/dms"
|
USER_MATUGEN_DIR="$CONFIG_DIR/matugen/dms"
|
||||||
|
|
||||||
@@ -118,8 +122,12 @@ EOF
|
|||||||
cat "$SHELL_DIR/matugen/configs/vesktop.toml" >> "$TMP_CFG"
|
cat "$SHELL_DIR/matugen/configs/vesktop.toml" >> "$TMP_CFG"
|
||||||
echo "" >> "$TMP_CFG"
|
echo "" >> "$TMP_CFG"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Load user's matugen configurations
|
if [[ "$run_user_templates" == "true" ]] && [[ -f "$CONFIG_DIR/matugen/config.toml" ]]; then
|
||||||
|
grep -v '^\[config\]' "$CONFIG_DIR/matugen/config.toml" >> "$TMP_CFG"
|
||||||
|
echo "" >> "$TMP_CFG"
|
||||||
|
fi
|
||||||
|
|
||||||
for config in "$USER_MATUGEN_DIR/configs"/*.toml; do
|
for config in "$USER_MATUGEN_DIR/configs"/*.toml; do
|
||||||
[[ -f "$config" ]] || continue
|
[[ -f "$config" ]] || continue
|
||||||
cat "$config" >> "$TMP_CFG"
|
cat "$config" >> "$TMP_CFG"
|
||||||
|
|||||||
Reference in New Issue
Block a user