mirror of
https://github.com/zephrynis/nix-flake.git
synced 2026-02-19 04:21:55 +00:00
feat: make AGS colorshell configuration fully declarative
- Add complete colorshell v2.0.3 configuration to home/ags-config/ - Disable runner plugin and NightLight tile (incompatible with NixOS) - Customize SCSS with full opacity (no transparency) - Add dark pale blue color scheme in home/pywal-colors/ - Configure Papirus-Dark icon theme via home-manager - Make ~/.config/ags/ immutable and managed by Nix store - Auto-deploy pywal colors to ~/.cache/wal/colors.json All AGS configuration is now reproducible and version controlled.
This commit is contained in:
18
home/ags-config/runner/plugins/apps.ts
Normal file
18
home/ags-config/runner/plugins/apps.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
import { execApp, getAstalApps, lookupIcon, updateApps } from "../../modules/apps";
|
||||
import { Runner } from "../Runner";
|
||||
|
||||
export const PluginApps = {
|
||||
// Do not provide prefix, so it always runs.
|
||||
name: "Apps",
|
||||
// asynchronously-refresh apps list on init
|
||||
init: async () => updateApps(),
|
||||
handle: (text: string) => {
|
||||
return getAstalApps().fuzzy_query(text).map(app => ({
|
||||
title: app.get_name(),
|
||||
description: app.get_description(),
|
||||
icon: lookupIcon(app.iconName) ? app.iconName : "application-x-executable-symbolic",
|
||||
actionClick: () => execApp(app)
|
||||
})
|
||||
);
|
||||
}
|
||||
} as Runner.Plugin;
|
||||
62
home/ags-config/runner/plugins/clipboard.ts
Normal file
62
home/ags-config/runner/plugins/clipboard.ts
Normal file
@@ -0,0 +1,62 @@
|
||||
import { Gtk } from "ags/gtk4";
|
||||
import { Clipboard, ClipboardItem } from "../../modules/clipboard";
|
||||
import { Runner } from "../Runner";
|
||||
import { jsx } from "ags/gtk4/jsx-runtime";
|
||||
|
||||
import Fuse from "fuse.js";
|
||||
|
||||
|
||||
class _PluginClipboard implements Runner.Plugin {
|
||||
#fuse!: Fuse<unknown>;
|
||||
prefix = '>';
|
||||
prioritize = true;
|
||||
|
||||
init() {
|
||||
const items: ReadonlyArray<ClipboardItem> = [...Clipboard.getDefault().history];
|
||||
this.#fuse = new Fuse(
|
||||
items,
|
||||
{
|
||||
keys: [ "id", "preview" ] satisfies Array<keyof ClipboardItem>,
|
||||
ignoreDiacritics: false,
|
||||
isCaseSensitive: false,
|
||||
shouldSort: true,
|
||||
useExtendedSearch: false
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
private clipboardResult(item: ClipboardItem): Runner.Result {
|
||||
return {
|
||||
icon: jsx(Gtk.Label, {
|
||||
label: `${item.id}`,
|
||||
css: "font-size: 16px; margin-right: 8px; font-weight: 600;"
|
||||
}),
|
||||
title: item.preview,
|
||||
actionClick: () => Clipboard.getDefault().selectItem(item).catch((err: Error) => {
|
||||
console.error(`Runner(Plugin/Clipboard): An error occurred while selecting clipboard item. Stderr:\n${
|
||||
err.message ? `${err.message}\n` : ""}Stack: ${err.stack}`
|
||||
);
|
||||
})
|
||||
};
|
||||
}
|
||||
|
||||
async handle(search: string, limit?: number) {
|
||||
if(Clipboard.getDefault().history.length < 1)
|
||||
return {
|
||||
icon: "edit-paste-symbolic",
|
||||
title: "Clipboard is empty",
|
||||
description: "Copy something and it will be shown right here!"
|
||||
};
|
||||
|
||||
if(search.trim().length === 0)
|
||||
return Clipboard.getDefault().history.map(item =>
|
||||
this.clipboardResult(item)
|
||||
);
|
||||
|
||||
return this.#fuse.search(search, {
|
||||
limit: limit ?? Infinity
|
||||
}).map(result => this.clipboardResult(result.item as ClipboardItem))
|
||||
}
|
||||
}
|
||||
|
||||
export const PluginClipboard = new _PluginClipboard();
|
||||
18
home/ags-config/runner/plugins/index.ts
Normal file
18
home/ags-config/runner/plugins/index.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
import { PluginApps } from "./apps"
|
||||
import { PluginClipboard } from "./clipboard"
|
||||
import { PluginMedia } from "./media"
|
||||
import { PluginShell } from "./shell"
|
||||
import { PluginWallpapers } from "./wallpapers"
|
||||
import { PluginWebSearch } from "./websearch"
|
||||
import { PluginKill } from "./kill"
|
||||
|
||||
|
||||
export {
|
||||
PluginApps,
|
||||
PluginWebSearch,
|
||||
PluginClipboard,
|
||||
PluginShell,
|
||||
PluginMedia,
|
||||
PluginWallpapers,
|
||||
PluginKill
|
||||
};
|
||||
18
home/ags-config/runner/plugins/kill.ts
Normal file
18
home/ags-config/runner/plugins/kill.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
import { execAsync } from "ags/process";
|
||||
import { Runner } from "../Runner";
|
||||
import { Notifications } from "../../modules/notifications";
|
||||
|
||||
export const PluginKill = {
|
||||
prefix: ":k",
|
||||
handle: () => ({
|
||||
title: "Select a client to kill",
|
||||
closeOnClick: true,
|
||||
icon: "window-close-symbolic",
|
||||
actionClick: () => execAsync("hyprctl kill").catch((e) =>
|
||||
Notifications.getDefault().sendNotification({
|
||||
summary: "Couldn't kill client",
|
||||
body: `An error occurred while trying to kill a client! Stderr: ${e}`
|
||||
})
|
||||
)
|
||||
} satisfies Runner.Result)
|
||||
} satisfies Runner.Plugin;
|
||||
99
home/ags-config/runner/plugins/media.ts
Normal file
99
home/ags-config/runner/plugins/media.ts
Normal file
@@ -0,0 +1,99 @@
|
||||
import { createBinding, createComputed } from "ags";
|
||||
import { Runner } from "../Runner";
|
||||
import { secureBaseBinding } from "../../modules/utils";
|
||||
import { tr } from "../../i18n/intl";
|
||||
|
||||
import Media from "../../modules/media";
|
||||
import AstalMpris from "gi://AstalMpris";
|
||||
|
||||
|
||||
export const PluginMedia = {
|
||||
prefix: ":",
|
||||
handle: () => !Media.getDefault().player.available ? {
|
||||
icon: "folder-music-symbolic",
|
||||
title: "Couldn't find any players",
|
||||
closeOnClick: false,
|
||||
description: "No media / player found with mpris"
|
||||
} : [
|
||||
{
|
||||
icon: secureBaseBinding<AstalMpris.Player>(
|
||||
createBinding(Media.getDefault(), "player"),
|
||||
"playbackStatus",
|
||||
AstalMpris.PlaybackStatus.PAUSED
|
||||
).as((status) => status === AstalMpris.PlaybackStatus.PLAYING ?
|
||||
"media-playback-pause-symbolic"
|
||||
: "media-playback-start-symbolic"),
|
||||
closeOnClick: false,
|
||||
title: createComputed([
|
||||
secureBaseBinding<AstalMpris.Player>(
|
||||
createBinding(Media.getDefault(), "player"),
|
||||
"title",
|
||||
null
|
||||
).as(t => t ?? tr("media.no_title")),
|
||||
secureBaseBinding<AstalMpris.Player>(
|
||||
createBinding(Media.getDefault(), "player"),
|
||||
"artist",
|
||||
null
|
||||
).as(t => t ?? tr("media.no_artist")),
|
||||
secureBaseBinding<AstalMpris.Player>(
|
||||
createBinding(Media.getDefault(), "player"),
|
||||
"playbackStatus",
|
||||
AstalMpris.PlaybackStatus.PAUSED
|
||||
)
|
||||
], (title, artist, status) => `${status === AstalMpris.PlaybackStatus.PLAYING ?
|
||||
"Pause" : "Play"
|
||||
} ${title} | ${artist}`),
|
||||
actionClick: () => Media.getDefault().player.play_pause()
|
||||
},
|
||||
{
|
||||
icon: "media-skip-backward-symbolic",
|
||||
closeOnClick: false,
|
||||
title: createComputed([
|
||||
secureBaseBinding<AstalMpris.Player>(
|
||||
createBinding(Media.getDefault(), "player"),
|
||||
"title",
|
||||
null
|
||||
).as(t => t ?? tr("media.no_title")),
|
||||
secureBaseBinding<AstalMpris.Player>(
|
||||
createBinding(Media.getDefault(), "player"),
|
||||
"artist",
|
||||
null
|
||||
).as(t => t ?? tr("media.no_artist")),
|
||||
secureBaseBinding<AstalMpris.Player>(
|
||||
createBinding(Media.getDefault(), "player"),
|
||||
"identity",
|
||||
"Music Player"
|
||||
)
|
||||
], (title, artist, identity) =>
|
||||
`Go Previous ${title ? title : identity}${artist ? ` | ${artist}` : ""}`
|
||||
),
|
||||
actionClick: () => Media.getDefault().player.canGoPrevious &&
|
||||
Media.getDefault().player.previous()
|
||||
},
|
||||
{
|
||||
icon: "media-skip-forward-symbolic",
|
||||
closeOnClick: false,
|
||||
title: createComputed([
|
||||
secureBaseBinding<AstalMpris.Player>(
|
||||
createBinding(Media.getDefault(), "player"),
|
||||
"title",
|
||||
null
|
||||
).as(t => t ?? tr("media.no_title")),
|
||||
secureBaseBinding<AstalMpris.Player>(
|
||||
createBinding(Media.getDefault(), "player"),
|
||||
"artist",
|
||||
null
|
||||
).as(t => t ?? tr("media.no_artist")),
|
||||
secureBaseBinding<AstalMpris.Player>(
|
||||
createBinding(Media.getDefault(), "player"),
|
||||
"identity",
|
||||
"Music Player"
|
||||
)
|
||||
], (title, artist, identity) =>
|
||||
`Go Next ${title ? title : identity}${artist ? ` | ${artist}` : ""}`
|
||||
),
|
||||
actionClick: () => Media.getDefault().player.canGoNext &&
|
||||
Media.getDefault().player.next()
|
||||
}
|
||||
]
|
||||
} as Runner.Plugin;
|
||||
65
home/ags-config/runner/plugins/shell.ts
Normal file
65
home/ags-config/runner/plugins/shell.ts
Normal file
@@ -0,0 +1,65 @@
|
||||
import { Runner } from "../Runner";
|
||||
import { Notifications } from "../../modules/notifications";
|
||||
|
||||
import GLib from "gi://GLib?version=2.0";
|
||||
import Gio from "gi://Gio?version=2.0";
|
||||
|
||||
|
||||
export const PluginShell = (() => {
|
||||
|
||||
const shell = GLib.getenv("SHELL") ?? "/bin/sh";
|
||||
const procLauncher = Gio.SubprocessLauncher.new(
|
||||
Gio.SubprocessFlags.STDOUT_PIPE | Gio.SubprocessFlags.STDERR_PIPE);
|
||||
|
||||
procLauncher.set_cwd(GLib.get_home_dir());
|
||||
|
||||
return {
|
||||
prefix: '!',
|
||||
prioritize: true,
|
||||
handle: (input) => {
|
||||
let showOutputNotif: boolean = false;
|
||||
if(input.startsWith('!')) {
|
||||
input = input.replace('!', "");
|
||||
showOutputNotif = true;
|
||||
}
|
||||
|
||||
const command = input ? GLib.shell_parse_argv(input) : undefined;
|
||||
const shellSplit = shell.split('/'),
|
||||
shellName = shellSplit[shellSplit.length-1];
|
||||
|
||||
return {
|
||||
actionClick: () => {
|
||||
if(!command?.[0] || !command[1]) return;
|
||||
|
||||
const proc = procLauncher.spawnv([ shell, "-c", `${input}` ]);
|
||||
proc.communicate_utf8_async(null, null, (_, asyncResult) => {
|
||||
const [ success, stdout, stderr ] = proc.communicate_utf8_finish(asyncResult);
|
||||
|
||||
if(!success || stderr) {
|
||||
Notifications.getDefault().sendNotification({
|
||||
appName: shell,
|
||||
summary: "Command error",
|
||||
body: `An error occurred on \`${input}\`. Stderr: ${stderr}`
|
||||
});
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if(!showOutputNotif) return;
|
||||
|
||||
Notifications.getDefault().sendNotification({
|
||||
appName: shell,
|
||||
summary: "Command output",
|
||||
body: stdout
|
||||
});
|
||||
});
|
||||
},
|
||||
title: `Run ${input ? ` \`${input}\`` : `with ${shellName}`}`,
|
||||
description: input || showOutputNotif ? `${input ? `${shell}\t` : ""}${
|
||||
showOutputNotif ? "(showing output on notification)" : "" }`
|
||||
: "",
|
||||
icon: "utilities-terminal-symbolic"
|
||||
};
|
||||
}
|
||||
} as Runner.Plugin
|
||||
})();
|
||||
63
home/ags-config/runner/plugins/wallpapers.ts
Normal file
63
home/ags-config/runner/plugins/wallpapers.ts
Normal file
@@ -0,0 +1,63 @@
|
||||
import Fuse from "fuse.js";
|
||||
import { Wallpaper } from "../../modules/wallpaper";
|
||||
import { Runner } from "../Runner";
|
||||
|
||||
import Gio from "gi://Gio?version=2.0";
|
||||
|
||||
|
||||
class _PluginWallpapers implements Runner.Plugin {
|
||||
prefix = "#";
|
||||
prioritize = true;
|
||||
#fuse!: Fuse<string>;
|
||||
#files!: Array<string>;
|
||||
|
||||
init() {
|
||||
this.#files = [];
|
||||
const dir = Gio.File.new_for_path(Wallpaper.getDefault().wallpapersPath);
|
||||
if(dir.query_file_type(null, null) === Gio.FileType.DIRECTORY) {
|
||||
for(const file of dir.enumerate_children(
|
||||
"standard::*",
|
||||
Gio.FileQueryInfoFlags.NOFOLLOW_SYMLINKS,
|
||||
null
|
||||
)) {
|
||||
this.#files.push(`${dir.get_path()}/${file.get_name()}`);
|
||||
}
|
||||
}
|
||||
|
||||
this.#fuse = new Fuse<string>(
|
||||
this.#files as ReadonlyArray<string>,
|
||||
{
|
||||
useExtendedSearch: false,
|
||||
shouldSort: true,
|
||||
isCaseSensitive: false
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
private wallpaperResult(path: string): Runner.Result {
|
||||
return {
|
||||
title: path.split('/')[path.split('/').length-1].replace(/\..*$/, ""),
|
||||
actionClick: () => Wallpaper.getDefault().setWallpaper(path)
|
||||
};
|
||||
}
|
||||
|
||||
handle(search: string, limit?: number) {
|
||||
if(search.trim().length === 0)
|
||||
return this.#files.map(path =>
|
||||
this.wallpaperResult(path)
|
||||
);
|
||||
|
||||
if(this.#files.length > 0)
|
||||
return this.#fuse.search(search, {
|
||||
limit: limit ?? Infinity
|
||||
}).map(result => this.wallpaperResult(result.item));
|
||||
|
||||
return {
|
||||
title: "No wallpapers found!",
|
||||
description: "Define the $WALLPAPERS variable on Hyprland or create a ~/wallpapers directory",
|
||||
icon: "image-missing-symbolic"
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
export const PluginWallpapers = new _PluginWallpapers();
|
||||
27
home/ags-config/runner/plugins/websearch.ts
Normal file
27
home/ags-config/runner/plugins/websearch.ts
Normal file
@@ -0,0 +1,27 @@
|
||||
import AstalHyprland from "gi://AstalHyprland";
|
||||
import { Runner } from "../Runner";
|
||||
|
||||
|
||||
const searchEngines = {
|
||||
duckduckgo: "https://duckduckgo.com/?q=",
|
||||
google: "https://google.com/search?q=",
|
||||
yahoo: "https://search.yahoo.com/search?p="
|
||||
};
|
||||
|
||||
let engine: string = searchEngines.google;
|
||||
|
||||
export const PluginWebSearch = {
|
||||
prefix: '?',
|
||||
name: "Web Search",
|
||||
prioritize: true,
|
||||
|
||||
handle: (search) => ({
|
||||
icon: "system-search-symbolic",
|
||||
title: search || "Type your search...",
|
||||
description: `Search the Web`,
|
||||
actionClick: () => AstalHyprland.get_default().dispatch(
|
||||
"exec",
|
||||
`xdg-open \"${engine + search}\"`
|
||||
)
|
||||
})
|
||||
} as Runner.Plugin;
|
||||
Reference in New Issue
Block a user