Skip to content

Commit

Permalink
Merge branch 'experimental-ags' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
JaKooLit committed May 4, 2024
2 parents e27bc1e + e29068d commit 962a09d
Show file tree
Hide file tree
Showing 24 changed files with 1,786 additions and 1 deletion.
31 changes: 31 additions & 0 deletions config/ags/config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
"use strict";
import GLib from 'gi://GLib';
import App from 'resource:///com/github/Aylur/ags/app.js'
import userOptions from './modules/.configuration/user_options.js';
import Overview from './modules/overview/main.js';

const COMPILED_STYLE_DIR = `${GLib.get_user_config_dir()}/ags/user/`

async function applyStyle() {

App.resetCss();
App.applyCss(`${COMPILED_STYLE_DIR}/style.css`);
console.log('[LOG] Styles loaded')
}
applyStyle().catch(print);

const Windows = () => [
Overview()
];
const CLOSE_ANIM_TIME = 210;
App.config({
css: `${COMPILED_STYLE_DIR}/style.css`,
stackTraceOnError: true,
closeWindowDelay: {
'sideright': CLOSE_ANIM_TIME,
'sideleft': CLOSE_ANIM_TIME,
'osk': CLOSE_ANIM_TIME,
},
windows: Windows().flat(1),
});

121 changes: 121 additions & 0 deletions config/ags/modules/.configuration/user_options.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@

import userOverrides from '../../user_options.js';

// Defaults
let configOptions = {
// General stuff
'ai': {
'defaultGPTProvider': "openai",
'defaultTemperature': 0.9,
'enhancements': true,
'useHistory': true,
'writingCursor': " ...", // Warning: Using weird characters can mess up Markdown rendering
},
'animations': {
'choreographyDelay': 35,
'durationSmall': 110,
'durationLarge': 180,
},
'appearance': {
'keyboardUseFlag': false, // Use flag emoji instead of abbreviation letters
},
'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': 20,
'imageAllowNsfw': false,
},
'search': {
'engineBaseUrl': "https://www.google.com/search?q=",
'excludedSites': [], //add site to exclude from result. eg: "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",
},
'options': { // Right sidebar
'nextTab': "Page_Down",
'prevTab': "Page_Up",
},
'pin': "Ctrl+p",
'cycleTab': "Ctrl+Tab",
'nextTab': "Ctrl+Page_Down",
'prevTab': "Ctrl+Page_Up",
},
},
}

// Override defaults with user's options
function overrideConfigRecursive(userOverrides, configOptions = {}) {
for (const [key, value] of Object.entries(userOverrides)) {
if (typeof value === 'object') {
overrideConfigRecursive(value, configOptions[key]);
} else {
configOptions[key] = value;
}
}
}
overrideConfigRecursive(userOverrides, configOptions);

globalThis['userOptions'] = configOptions;
export default configOptions;
13 changes: 13 additions & 0 deletions config/ags/modules/.miscutils/icons.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
const { Gtk } = imports.gi;

export function iconExists(iconName) {
let iconTheme = Gtk.IconTheme.get_default();
return iconTheme.has_icon(iconName);
}

export function substitute(str) {
if(userOptions.icons.substitutions[str]) return userOptions.icons.substitutions[str];

if (!iconExists(str)) str = str.toLowerCase().replace(/\s+/g, '-'); // Turn into kebab-case
return str;
}
4 changes: 4 additions & 0 deletions config/ags/modules/.miscutils/mathfuncs.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

export function clamp(x, min, max) {
return Math.min(Math.max(x, min), max);
}
54 changes: 54 additions & 0 deletions config/ags/modules/.miscutils/system.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
const { GLib } = imports.gi;
import Variable from 'resource:///com/github/Aylur/ags/variable.js';
import * as Utils from 'resource:///com/github/Aylur/ags/utils.js';
const { execAsync, exec } = Utils;

export const distroID = exec(`bash -c 'cat /etc/os-release | grep "^ID=" | cut -d "=" -f 2 | sed "s/\\"//g"'`).trim();
export const isDebianDistro = (distroID == 'linuxmint' || distroID == 'ubuntu' || distroID == 'debian' || distroID == 'zorin' || distroID == 'popos' || distroID == 'raspbian' || distroID == 'kali');
export const isArchDistro = (distroID == 'arch' || distroID == 'endeavouros' || distroID == 'cachyos');
export const hasFlatpak = !!exec(`bash -c 'command -v flatpak'`);

const LIGHTDARK_FILE_LOCATION = `${GLib.get_user_cache_dir()}/ags/user/colormode.txt`;
const colorMode = Utils.exec('bash -c "sed -n \'1p\' $HOME/.cache/ags/user/colormode.txt"');
export let darkMode = Variable(!(Utils.readFile(LIGHTDARK_FILE_LOCATION).split('\n')[0].trim() == 'light'));
export const hasPlasmaIntegration = !!Utils.exec('bash -c "command -v plasma-browser-integration-host"');

export const getDistroIcon = () => {
// Arches
if(distroID == 'arch') return 'arch-symbolic';
if(distroID == 'endeavouros') return 'endeavouros-symbolic';
if(distroID == 'cachyos') return 'cachyos-symbolic';
// Funny flake
if(distroID == 'nixos') return 'nixos-symbolic';
// Cool thing
if(distroID == 'fedora') return 'fedora-symbolic';
// Debians
if(distroID == 'linuxmint') return 'ubuntu-symbolic';
if(distroID == 'ubuntu') return 'ubuntu-symbolic';
if(distroID == 'debian') return 'debian-symbolic';
if(distroID == 'zorin') return 'ubuntu-symbolic';
if(distroID == 'popos') return 'ubuntu-symbolic';
if(distroID == 'raspbian') return 'debian-symbolic';
if(distroID == 'kali') return 'debian-symbolic';
return 'linux-symbolic';
}

export const getDistroName = () => {
// Arches
if(distroID == 'arch') return 'Arch Linux';
if(distroID == 'endeavouros') return 'EndeavourOS';
if(distroID == 'cachyos') return 'CachyOS';
// Funny flake
if(distroID == 'nixos') return 'NixOS';
// Cool thing
if(distroID == 'fedora') return 'Fedora';
// Debians
if(distroID == 'linuxmint') return 'Linux Mint';
if(distroID == 'ubuntu') return 'Ubuntu';
if(distroID == 'debian') return 'Debian';
if(distroID == 'zorin') return 'Zorin';
if(distroID == 'popos') return 'Pop!_OS';
if(distroID == 'raspbian') return 'Raspbian';
if(distroID == 'kali') return 'Kali Linux';
return 'Linux';
}
86 changes: 86 additions & 0 deletions config/ags/modules/.widgethacks/advancedrevealers.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
import Widget from 'resource:///com/github/Aylur/ags/widget.js';

const { Revealer, Scrollable } = Widget;

export const MarginRevealer = ({
transition = 'slide_down',
child,
revealChild,
showClass = 'element-show', // These are for animation curve, they don't really hide
hideClass = 'element-hide', // Don't put margins in these classes!
extraSetup = () => { },
...rest
}) => {
const widget = Scrollable({
...rest,
attribute: {
'revealChild': true, // It'll be set to false after init if it's supposed to hide
'transition': transition,
'show': () => {
if (widget.attribute.revealChild) return;
widget.hscroll = 'never';
widget.vscroll = 'never';
child.toggleClassName(hideClass, false);
child.toggleClassName(showClass, true);
widget.attribute.revealChild = true;
child.css = 'margin: 0px;';
},
'hide': () => {
if (!widget.attribute.revealChild) return;
child.toggleClassName(hideClass, true);
child.toggleClassName(showClass, false);
widget.attribute.revealChild = false;
if (widget.attribute.transition == 'slide_left')
child.css = `margin-right: -${child.get_allocated_width()}px;`;
else if (widget.attribute.transition == 'slide_right')
child.css = `margin-left: -${child.get_allocated_width()}px;`;
else if (widget.attribute.transition == 'slide_up')
child.css = `margin-bottom: -${child.get_allocated_height()}px;`;
else if (widget.attribute.transition == 'slide_down')
child.css = `margin-top: -${child.get_allocated_height()}px;`;
},
'toggle': () => {
if (widget.attribute.revealChild) widget.attribute.hide();
else widget.attribute.show();
},
},
child: child,
hscroll: `${revealChild ? 'never' : 'always'}`,
vscroll: `${revealChild ? 'never' : 'always'}`,
setup: (self) => {
extraSetup(self);
}
});
child.toggleClassName(`${revealChild ? showClass : hideClass}`, true);
return widget;
}

// TODO: Allow reveal update. Currently this just helps at declaration
export const DoubleRevealer = ({
transition1 = 'slide_right',
transition2 = 'slide_left',
duration1 = 150,
duration2 = 150,
child,
revealChild,
...rest
}) => {
const r2 = Revealer({
transition: transition2,
transitionDuration: duration2,
revealChild: revealChild,
child: child,
});
const r1 = Revealer({
transition: transition1,
transitionDuration: duration1,
revealChild: revealChild,
child: r2,
...rest,
})
r1.toggleRevealChild = (value) => {
r1.revealChild = value;
r2.revealChild = value;
}
return r1;
}
32 changes: 32 additions & 0 deletions config/ags/modules/.widgethacks/popupwindow.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import App from 'resource:///com/github/Aylur/ags/app.js';
import Widget from 'resource:///com/github/Aylur/ags/widget.js';
const { Box, Window } = Widget;


export default ({
name,
child,
showClassName = "",
hideClassName = "",
...props
}) => {
return Window({
name,
visible: false,
layer: 'overlay',
...props,

child: Box({
setup: (self) => {
self.hook(App, (self, currentName, visible) => {
if (currentName === name) {
self.toggleClassName(hideClassName, !visible);
}
}).keybind("Escape", () => App.closeWindow(name))
if (showClassName !== "" && hideClassName !== "")
self.className = `${showClassName} ${hideClassName}`;
},
child: child,
}),
});
}
4 changes: 4 additions & 0 deletions config/ags/modules/.widgetutils/clickthrough.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import Cairo from 'gi://cairo?version=1.0';

export const dummyRegion = new Cairo.Region();
export const enableClickthrough = (self) => self.input_shape_combine_region(dummyRegion);
Loading

0 comments on commit 962a09d

Please sign in to comment.