allow user config (related: #271) (closes #318)

This commit is contained in:
end-4 2024-03-12 14:43:30 +07:00
parent ca7024b550
commit 32956fda25
3 changed files with 110 additions and 80 deletions

View file

@ -5,7 +5,7 @@ import GLib from 'gi://GLib';
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 './user_options.js';
import userOptions from './modules/.configuration/user_options.js';
// Widgets
import { Bar, BarCornerTopleft, BarCornerTopright } from './modules/bar/main.js';
import Cheatsheet from './modules/cheatsheet/main.js';

View file

@ -0,0 +1,104 @@
import userOverrides from '../../user_options.js';
// Defaults
let configOptions = {
// General stuff
'ai': {
'defaultGPTProvider': "openai",
'defaultTemperature': 0.9,
'writingCursor': " ...", // Warning: Using weird characters can mess up Markdown rendering
},
'animations': {
'durationSmall': 110,
'durationLarge': 180,
},
'apps': {
'imageViewer': "loupe",
'terminal': "foot", // This is only for shell actions
},
'battery': {
'low': 20,
'critical': 10,
},
'music': {
'preferredPlayer': "plasma-browser-integration",
},
'onScreenKeyboard': {
'layout': "qwerty_full", // See modules/onscreenkeyboard/onscreenkeyboard.js for available layouts
},
'overview': {
'scale': 0.18, // Relative to screen size
'numOfRows': 2,
'numOfCols': 5,
'wsNumScale': 0.09,
'wsNumMarginScale': 0.07,
},
'sidebar': {
'imageColumns': 2,
'imageBooruCount': 6,
},
'search': {
'engineBaseUrl': "https://www.google.com/search?q=",
'excludedSites': ["quora.com"],
},
'time': {
// See https://docs.gtk.org/glib/method.DateTime.format.html
// Here's the 12h format: "%I:%M%P"
// For seconds, add "%S" and set interval to 1000
'format': "%H:%M",
'interval': 5000,
'dateFormatLong': "%A, %d/%m", // On bar
'dateInterval': 5000,
'dateFormat': "%d/%m", // On notif time
},
'weather': {
'city': "",
},
'workspaces': {
'shown': 10,
},
// Longer stuff
'icons': {
substitutions: {
'code-url-handler': "visual-studio-code",
'Code': "visual-studio-code",
'GitHub Desktop': "github-desktop",
'Minecraft* 1.20.1': "minecraft",
'gnome-tweaks': "org.gnome.tweaks",
'pavucontrol-qt': "pavucontrol",
'wps': "wps-office2019-kprometheus",
'wpsoffice': "wps-office2019-kprometheus",
'': "image-missing",
}
},
'keybinds': {
// Format: Mod1+Mod2+key. CaSe SeNsItIvE!
// Modifiers: Shift Ctrl Alt Hyper Meta
// See https://docs.gtk.org/gdk3/index.html#constants for the other keys (they are listed as KEY_key)
'overview': {
'altMoveLeft': "Ctrl+b",
'altMoveRight': "Ctrl+f",
'deleteToEnd': "Ctrl+k",
},
'sidebar': {
'apis': {
'nextTab': "Page_Down",
'prevTab': "Page_Up",
},
'pin': "Ctrl+p",
'cycleTab': "Ctrl+Tab",
'nextTab': "Ctrl+Page_Down",
'prevTab': "Ctrl+Page_Up",
},
},
}
// Load user's options
Object.entries(userOverrides).forEach((override) => {
const [key, value] = override;
configOptions[key] = value;
});
globalThis['userOptions'] = configOptions;
export default configOptions;

View file

@ -1,82 +1,9 @@
let userConfigOptions = {
// General stuff
'ai': {
'defaultGPTProvider': "openai",
'defaultTemperature': 0.9,
'writingCursor': " ...", // Warning: Using weird characters can mess up Markdown rendering
},
'animations': {
'durationSmall': 110,
'durationLarge': 180,
},
'apps': {
'imageViewer': "loupe",
'terminal': "foot", // This is only for shell actions
},
'battery': {
'low': 20,
'critical': 10,
},
'music': {
'preferredPlayer': "plasma-browser-integration",
},
'onScreenKeyboard': {
'layout': "qwerty_full", // See modules/onscreenkeyboard/onscreenkeyboard.js for available layouts
},
'overview': {
'scale': 0.18, // Relative to screen size
'numOfRows': 2,
'numOfCols': 5,
'wsNumScale': 0.09,
'wsNumMarginScale': 0.07,
},
'sidebar': {
'imageColumns': 2,
},
'search': {
'engineBaseUrl': "https://www.google.com/search?q=",
'excludedSites': ["quora.com"],
},
'time': {
// See https://docs.gtk.org/glib/method.DateTime.format.html
// Here's the 12h format: "%I:%M%P"
// For seconds, add "%S" and set interval to 1000
'format': "%H:%M",
'interval': 5000,
'dateFormatLong': "%A, %d/%m", // On bar
'dateInterval': 5000,
'dateFormat': "%d/%m", // On notif time
},
'weather': {
'city': "",
},
'workspaces': {
'shown': 10,
},
// Longer stuff
'icons': {
substitutions: {
'code-url-handler': "visual-studio-code",
'Code': "visual-studio-code",
'GitHub Desktop': "github-desktop",
'Minecraft* 1.20.1': "minecraft",
'gnome-tweaks': "org.gnome.tweaks",
'pavucontrol-qt': "pavucontrol",
'wps': "wps-office2019-kprometheus",
'wpsoffice': "wps-office2019-kprometheus",
'': "image-missing",
}
},
const userConfigOptions = {
// For every option, see ~/.config/ags/modules/.configuration/user_options.js (vscode users ctrl+click this file://./modules/.configuration/user_options.js)
// Options listed in this file will override the default ones in the above file
// Here's an example
'keybinds': {
// Format: Mod1+Mod2+key. CaSe SeNsItIvE!
// Modifiers: Shift Ctrl Alt Hyper Meta
// See https://docs.gtk.org/gdk3/index.html#constants for the other keys (they are listed as KEY_key)
'overview': {
'altMoveLeft': "Ctrl+b",
'altMoveRight': "Ctrl+f",
'deleteToEnd': "Ctrl+k",
},
'sidebar': {
'apis': {
'nextTab': "Page_Down",
@ -90,5 +17,4 @@ let userConfigOptions = {
},
}
globalThis['userOptions'] = userConfigOptions;
export default userOptions;
export default userConfigOptions;