Skip to content

Commit

Permalink
main
Browse files Browse the repository at this point in the history
  • Loading branch information
zyqunix committed Jan 14, 2025
1 parent 1427b94 commit 8a89542
Show file tree
Hide file tree
Showing 234 changed files with 25,302 additions and 0 deletions.
2 changes: 2 additions & 0 deletions ags/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules/
@girs/
15 changes: 15 additions & 0 deletions ags/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@

# Starter Config

if suggestions don't work, first make sure
you have TypeScript LSP working in your editor

if you do not want typechecking only suggestions

```json
// tsconfig.json
"checkJs": false
```

types are symlinked to:
/usr/local/share/com.github.Aylur.ags/types
10 changes: 10 additions & 0 deletions ags/app.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { App } from "astal/gtk3"
import style from "./style.scss"
import Bar from "./widget/Bar"

App.start({
css: style,
main() {
App.get_monitors().map(Bar)
},
})
31 changes: 31 additions & 0 deletions 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),
});

21 changes: 21 additions & 0 deletions ags/env.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
declare const SRC: string

declare module "inline:*" {
const content: string
export default content
}

declare module "*.scss" {
const content: string
export default content
}

declare module "*.blp" {
const content: string
export default content
}

declare module "*.css" {
const content: string
export default content
}
126 changes: 126 additions & 0 deletions ags/modules/.configuration/user_options.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@

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': 55,
'durationLarge': 90,
},
'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: {
'codium-url-handler': "vscodium",
'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",
'eu.betterbird.Betterbird' : "thunderbird",
'thunderbird-esr': "thunderbird",
'wps': "wps-office2019-kprometheus",
'wpsoffice': "wps-office2019-kprometheus",
'firefox-esr': "firefox",
'soffice' : "libreoffice",
'': "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 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 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 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 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;
}
Loading

0 comments on commit 8a89542

Please sign in to comment.