Update 3 files

- /home/.chezmoiscripts/universal/run_onchange_after_20-apply-settings.tmpl
- /home/.chezmoitemplates/universal/zx
- /home/private_dot_config/xsettingsd/xsettingsd.conf
This commit is contained in:
Brian Zalewski 2023-01-05 09:09:21 +00:00
parent a8e6bf0e84
commit ea10ebba44
3 changed files with 193 additions and 14 deletions

View file

@ -0,0 +1,94 @@
#!/usr/bin/env zx
// gnome config hash: {{ include (joinPath .host.home ".config" "desktop" "gnome.yml")| sha256sum }}
// settings config hash: {{ include (joinPath .host.home ".config" "desktop" "settings.yml")| sha256sum }}
{{ includeTemplate "universal/zx" }}
async function loadThemeSettings() {
try {
const themeSettingsFile = `${process.env.HOME}/.config/desktop/settings.yml`
if (fileExists(settingsFile)) {
const text = fs.readFileSync(themeSettingsFile).toString()
return YAML.parse(text)
} else {
log('warn', 'File Missing', 'Could not find ~/.config/desktop/settings.yml')
return {}
}
} catch (e) {
log('error', 'File Load Error', 'Failed to read the ~/.config/desktop/settings.yml file')
console.error(e)
return {}
}
}
async function loadGnomeSettings() {
try {
const gnomeSettingsFile = `${process.env.HOME}/.config/desktop/gnome.yml`
if (fileExists(settingsFile)) {
const text = fs.readFileSync(gnomeSettingsFile).toString()
return YAML.parse(text)
} else {
log('warn', 'File Missing', 'Could not find ~/.config/desktop/gnome.yml')
return {}
}
} catch (e) {
log('error', 'File Load Error', 'Failed to read the ~/.config/desktop/gnome.yml file')
console.error(e)
return {}
}
}
async function applyGsettings(settings) {
for (const setting of settings) {
try {
await $`gsettings set ${setting.setting} ${setting.value}`
} catch (e) {
log('error', 'Gsettings Failure', 'Failed to apply gsetting')
console.error(e)
}
}
}
async function applyXconfSettings(settings) {
for (const setting of settings) {
try {
const xfconfType = setting.value_type ? setting.value_type : 'string'
await $`xfconf-query --channel '${setting.channel}' --property '${setting.property}' --type ${xfconfType} --set ${setting.value}`
} catch (e) {
log('error', 'Xfconf Failure', 'Failed to apply gsetting')
console.error(e)
}
}
}
async function applyDconfSettings(settings) {
for (const setting of settings) {
try {
await $`dconf write ${setting.key} ${setting.value}`
} catch (e) {
log('error', 'Dconf Failure', 'Failed to apply dconf setting')
console.error(e)
}
}
}
async function main() {
const promises = [loadThemeSettings(), loadGnomeSettings()]
const results = await Promise.all(promises)
const themeSettings = results[0]
const gnomeSettings = results[1]
if (themeSettings && themeSettings.gsetting_configs) {
settingsPromises.push(applyGsettings(themeSettings.gsetting_configs))
}
if (themeSettings && themeSettings.xconf_settings) {
settingsPromises.push(applyXconfSettings(themeSettings.xconf_settings))
}
if (gnomeSettings && gnomeSettings.default_dconf_settings) {
settingsPromises.push(applyDconfSettings(gnomeSettings.default_dconf_settings))
}
await Promise.all(settingsPromises)
log('success', 'Settings', 'Successfully applied all valid gsettings / xconf / dconf settings')
}
main()

View file

@ -0,0 +1,83 @@
const execSync = require('child_process').execSync
// Log symbols
const figuresDefault = {
bullet: '●',
circle: '◯',
cross: '✖',
lozenge: '◆',
play: '▶',
pointer: '',
square: '◼',
star: '★',
tick: '✔'
}
const figuresFallback = {
bullet: '■',
circle: '□',
cross: '×',
lozenge: '♦',
play: '►',
pointer: '>',
square: '■',
star: '✶',
tick: '√'
}
function isUnicodeSupported() {
if (process.platform !== 'win32') {
// Linux console (kernel)
return process.env.TERM !== 'linux'
}
return (
Boolean(process.env.CI) ||
// Windows Terminal
Boolean(process.env.WT_SESSION) ||
// ConEmu and cmder
process.env.ConEmuTask === '{cmd::Cmder}' ||
process.env.TERM_PROGRAM === 'vscode' ||
process.env.TERM === 'xterm-256color' ||
process.env.TERM === 'alacritty'
)
}
const figures = isUnicodeSupported() ? figuresDefault : figuresFallback
function log(type, label, msg) {
let icon, message
if (type === 'info') {
icon = chalk.cyanBright(figures.pointer)
message = chalk.gray.bold(msg)
} else if (type === 'star') {
icon = chalk.yellowBright(figures.star)
message = chalk.bold(msg)
} else if (type === 'success') {
icon = chalk.greenBright(figures.play)
message = chalk.bold(msg)
} else if (type === 'warn') {
icon = `${chalk.yellowBright(figures.lozenge)} ${chalk.bold.black.bgYellowBright(' WARNING ')}`
message = chalk.yellowBright(msg)
} else if (type === 'error') {
icon = `${chalk.redBright(figures.cross)} ${chalk.black.bold.bgRedBright(' ERROR ')}`
message = chalk.redBright(msg)
}
const outputMessage = `${icon} ${chalk.bold(label)} ${message}`
console.log(outputMessage)
}
function runCommand(spinnerTitle, command) {
execSync(`gum spin --spinner dot --title "${spinnerTitle}" -- ${command}`, {
stdio: 'inherit',
shell: true
})
}
async function runSilentCommand(command) {
execSync(`${command}`, { stdio: 'inherit', shell: true })
}
function fileExists(pathToFile) {
return fs.existsSync(pathToFile)
}

View file

@ -1,14 +1,16 @@
[Settings] # Source: https://wiki.archlinux.org/title/Xsettingsd#Configuration
gtk-application-prefer-dark-theme=1
gtk-button-images=1 Gtk/ButtonImages 1
gtk-cursor-theme-name=Betelgeuse Gtk/CursorThemeName "Betelgeuse"
gtk-decoration-layout=icon:minimize,maximize,close Gtk/CursorThemeSize 24
gtk-enable-animations=1 Gtk/DecorationLayout "icon:minimize,maximize,close"
gtk-font-name=Montserrat Medium, Medium 10 Gtk/EnableAnimations 1
gtk-icon-theme-name=Betelgeuse Gtk/FontName "Montserrat Bold 10"
gtk-menu-images=1 Gtk/MenuImages 1
gtk-modules=appmenu-gtk-module Gtk/MonospaceFontName "Hack Nerd Font 10"
gtk-primary-button-warps-slider=0 Gtk/ToolbarStyle 3
gtk-shell-shows-menubar=1 Net/IconThemeName "Betelgeuse"
gtk-theme-name=Betelgeuse Net/SoundThemeName "MIUI"
gtk-toolbar-style=GTK_TOOLBAR_BOTH_HORIZ Net/ThemeName "Betelgeuse"
Xfce/LastCustomDPI 100
Xft/DPI 100