diff --git a/config/ags/main.ts b/config/ags/main.ts index a937f614..cf0f1944 100644 --- a/config/ags/main.ts +++ b/config/ags/main.ts @@ -4,6 +4,7 @@ import Gdk from "gi://Gdk"; // widgets import { Bar, BarCornerTopLeft, BarCornerTopRight } from "./modules/bar.ts"; import { Notifications } from "./modules/notificationPopups.ts"; +import { cliphist } from "./modules/cliphist.ts"; import { sideright } from "./modules/sideright/main.ts"; import { sideleft } from "./modules/sideleft/main.ts"; import {} from "apps/settings/main.ts"; @@ -12,6 +13,7 @@ import { cheatsheet } from "modules/cheatsheet.ts"; import Window from "types/widgets/window"; import { popups } from "modules/popups.ts"; import { start_battery_warning_service } from "services/battery_warning.ts"; +import { audio_popup } from "./modules/audio.ts" import Gtk from "gi://Gtk?version=3.0"; const GLib = imports.gi.GLib; @@ -29,10 +31,12 @@ const Windows = () => [ forMonitors(Notifications), forMonitors(BarCornerTopLeft), forMonitors(BarCornerTopRight), + cliphist, sideright, cheatsheet, sideleft, forMonitors(popups), + audio_popup ]; App.config({ @@ -68,4 +72,3 @@ globalThis.ReloadColors = ReloadColors; globalThis.enableAnimations = enableAnimations; start_battery_warning_service(); - diff --git a/config/ags/modules/audio.ts b/config/ags/modules/audio.ts new file mode 100644 index 00000000..613ab20b --- /dev/null +++ b/config/ags/modules/audio.ts @@ -0,0 +1,243 @@ +import { Stream } from "types/service/audio"; +import popupwindow from "./misc/popupwindow.ts"; +import { MaterialIcon } from "icons.ts"; +const audio = await Service.import("audio"); +const WINDOW_NAME = "audio"; + +interface icons_type { + [key: string]: [number, string][]; +} + +const icons: icons_type = { + microphone: [ + [1, "mic"], + [0, "mic_off"] + ], + headset_mic: [ + [1, "headset_mic"], + [0, "headset_off"] + ], + speaker: [ + [101, "sound_detection_loud_sound"], + [67, "volume_up"], + [34, "volume_down"], + [1, "volume_mute"], + [0, "volume_off"] + ] +}; + +const off_icons = { + microphone: "mic_off", + headset_mic: "headset_off", + speaker: "volume_off" +}; +const button_with_icon = ( + icon: string, + size: string, + stream: Stream, + on_clicked: () => void, + icons: [number, string][], + off: string +) => + Widget.Button({ + child: MaterialIcon(icon, size).hook(stream, (self) => { + const vol = stream.volume * 100; + const icon = icons.find(([threshold]) => Number(threshold) <= vol)?.[1]; + if (stream.is_muted) self.label = off; + else self.label = String(icon!); + self.tooltip_text = `${Math.floor(stream.volume * 100)}%`; + }), + on_clicked: on_clicked + }); + +const create_slider = (stream: Stream) => + Widget.Slider({ + min: 0, + max: 100, + draw_value: false, + hexpand: true, + vpack: "end", + value: stream.volume * 100, + on_change: (self) => { + stream.volume = self.value / 100; + self.tooltip_text = `${Math.floor(stream.volume * 100)}%`; + }, + setup: (self) => { + self.hook(stream, () => { + self.max = stream.volume > 1 ? 150 : 100; + self.value = stream.volume * 100; + self.tooltip_text = `${Math.floor(stream.volume * 100)}%`; + }); + } + }); + +const speaker = (stream: Stream, icons: [number, string][], off: string) => + Widget.Box({ + class_name: "device", + vertical: true, + attribute: { stream: stream }, + children: [ + Widget.Label({ + label: stream.description, + hpack: "start", + xalign: 0, + truncate: "middle", + tooltip_text: stream.name + }), + Widget.Box({ + children: [ + button_with_icon( + off, + "20px", + stream, + () => { + stream.is_muted = !stream.is_muted; + }, + icons, + off + ), + create_slider(stream) + ] + }) + ] + }); + +const app = (stream: Stream) => { + const label = !!stream.name ? `${stream.name}: ${stream.description}` : stream.description; + return Widget.Box({ + class_name: "device", + vertical: true, + attribute: { stream: stream }, + children: [ + Widget.Label({ + label: label, + hpack: "start", + xalign: 0, + truncate: "middle", + tooltip_text: label + }), + Widget.Box({ + children: [ + Widget.Button({ + child: Widget.Icon({ icon: stream.icon_name || "image-missing", size: 20 }), + on_clicked: () => { + stream.is_muted = !stream.is_muted; + } + }), + create_slider(stream) + ] + }) + ] + }); +}; + +const tab = (icon: string, on_clicked: (any) => void, page?: string) => + Widget.Overlay({ + child: Widget.Button({ + hexpand: true, + vexpand: true, + on_clicked: on_clicked + }), + pass_through: true, + attribute: { page: page || icon }, + overlays: [MaterialIcon(icon, "22px")] + }); + +const audio_widget = () => { + const cur_page = Variable("speakers"); + const tabs = Widget.Box({ + class_name: "tabs", + children: [ + tab("volume_up", () => cur_page.setValue("speakers"), "speakers"), + tab("apps", () => cur_page.setValue("apps"), "apps") + ], + setup: (self) => { + self.hook(cur_page, () => { + self.children.forEach((widget) => { + widget.toggleClassName("active", widget.attribute.page == cur_page.value); + }); + }); + } + }); + const speakers = Widget.Box({ vertical: true, children: [] as ReturnType[] }); + const apps = Widget.Box({ vertical: true, children: [] as ReturnType[] }); + + function update() { + const speaker_ids = audio.speakers.map((s) => s.id); + const app_ids = audio.apps.map((s) => s.id); + const microphone_ids = audio.microphones.map((s) => s.id); + + speakers.children + .filter( + (widget) => + !speaker_ids.includes(widget.attribute.stream.id) && + !microphone_ids.includes(widget.attribute.stream.id) + ) + .forEach((widget) => widget.destroy()); + + apps.children + .filter((widget) => !app_ids.includes(widget.attribute.stream.id)) + .forEach((widget) => widget.destroy()); + + audio.speakers.forEach((s) => { + if (!speakers.children.some((v) => v.attribute.stream.id == s.id)) { + speakers.pack_start(speaker(s, icons.speaker, off_icons.speaker), false, false, 0); + } + }); + + audio.microphones.forEach((s) => { + if (!speakers.children.some((v) => v.attribute.stream.id == s.id)) { + const _icons = + s.icon_name == "audio-headset-analog-usb" + ? { off: off_icons.headset_mic, default: icons.headset_mic } + : { off: off_icons.microphone, default: icons.microphone }; + speakers.pack_start(speaker(s, _icons.default, _icons.off), false, false, 0); + } + }); + + audio.apps.forEach((s) => { + if (!apps.children.some((v) => v.attribute.stream.id == s.id)) { + apps.pack_start(app(s), false, false, 0); + } + }); + } + + update(); + ["notify::speakers", "notify::apps", "notify::microphones"].forEach((event) => { + audio.connect(event, () => { + if (audio_popup.visible) update(); + }); + }); + + const stack = Widget.Stack({ + children: { speakers, apps }, + // @ts-expect-error + shown: cur_page.bind(), + transition: "crossfade" + }); + + return Widget.Scrollable({ + child: Widget.Box({ + class_name: "audio_box", + vpack: "start", + vertical: true, + children: [tabs, stack] + }), + hscroll: "never", + setup: (self) => { + self.hook(App, (_, windowName, visible) => { + if (windowName !== WINDOW_NAME) return; + if (visible) update(); + }); + } + }); +}; + +export const audio_popup = popupwindow({ + name: WINDOW_NAME, + class_name: "audio", + visible: false, + keymode: "exclusive", + child: audio_widget(), + anchor: ["top", "right", "bottom"] +}); diff --git a/config/ags/modules/bar.ts b/config/ags/modules/bar.ts index d271b52f..7ce2d5c4 100644 --- a/config/ags/modules/bar.ts +++ b/config/ags/modules/bar.ts @@ -20,7 +20,6 @@ import config from "services/configuration.ts"; import { toggleAppsWindow, toggleMediaWindow } from "./sideleft/main.js"; import { Variable as VariableType } from "types/variable"; - const keyboard_layout = Variable("none"); hyprland.connect("keyboard-layout", (hyprland, keyboardname, layoutname) => { keyboard_layout.setValue(layoutname.trim().toLowerCase().substr(0, 2)); @@ -97,20 +96,10 @@ function getIconNameFromClass(windowClass: string) { return Utils.lookUpIcon(icon) ? icon : "image-missing"; } -function workspaces_ids_are_equal(arr1: Workspace[] | undefined, arr2: Workspace[] | undefined): boolean { - if (!arr1 || !arr2) return false; - if (arr1.length !== arr2.length) return false; - - return arr1.every((value, index) => { - return value.id === arr2[index].id; - }); -} - const dispatch = (ws: string) => hyprland.messageAsync(`dispatch workspace ${ws}`).catch(print); function Workspaces() { let workspaceButtons = new Map(); - let _old_workspaces: Workspace[]; const workspaceButtonsArray: VariableType[] | any> = Variable([]); function createWorkspaceButton(id: Number) { @@ -122,37 +111,32 @@ function Workspaces() { }); } - function updateWorkspaceButtons() { - const workspaces = hyprland.workspaces; - if (workspaces_ids_are_equal(workspaces, _old_workspaces)) { - return; + function initializeWorkspaceButtons() { + for (let i = 1; i <= 10; i++) { + workspaceButtons.set(i, createWorkspaceButton(i)); } - workspaces.sort((a, b) => a.id - b.id); - const updatedButtons = new Map(); - - workspaces.forEach(({ id }) => { - if (!workspaceButtons.has(id)) { - workspaceButtons.set(id, createWorkspaceButton(id)); - } - updatedButtons.set(id, workspaceButtons.get(id)); - }); - - workspaceButtons = updatedButtons; - _old_workspaces = workspaces; workspaceButtonsArray.setValue(Array.from(workspaceButtons.values())); } + function update() { + workspaceButtons.forEach((workspace) => { + const existingWorkspace = hyprland.workspaces.some((element) => element.id === workspace.attribute.id); + workspace.toggleClassName("exists", existingWorkspace); + }); + } + function activeWorkspace() { workspaceButtons.forEach((workspace, key) => { workspace.toggleClassName("active", workspace.attribute.id == hyprland.active.workspace.id); }); } - updateWorkspaceButtons(); + initializeWorkspaceButtons(); activeWorkspace(); + update(); hyprland.connect("notify::workspaces", () => { activeWorkspace(); - updateWorkspaceButtons(); + update(); }); hyprland.connect("notify::active", () => { activeWorkspace(); @@ -161,6 +145,7 @@ function Workspaces() { return Widget.EventBox({ onScrollUp: () => dispatch("+1"), onScrollDown: () => dispatch("-1"), + hpack: "center", child: Widget.Box({ children: workspaceButtonsArray.bind(), class_name: "workspaces" @@ -357,13 +342,6 @@ function Bluetooth() { }); } -const Applets = () => - Widget.Box({ - class_name: "bar_applets", - spacing: 5, - children: [Bluetooth(), Wifi()] - }); - function MediaPlayer() { let metadata = mpris.players[0]?.metadata; const button = Widget.Button({ @@ -474,34 +452,35 @@ function volumeIndicator() { return Widget.EventBox({ onScrollUp: () => (audio.speaker.volume += 0.01), onScrollDown: () => (audio.speaker.volume -= 0.01), - class_name: "filled_tonal_button volume_box", + class_name: "volume_box", child: Widget.Button({ - on_primary_click_release: () => Utils.execAsync("pavucontrol").catch(print), + on_primary_click_release: () => App.toggleWindow("audio"), + on_middle_click_release: () => Utils.execAsync("pavucontrol").catch(print), on_secondary_click_release: () => (audio.speaker.is_muted = !audio.speaker.is_muted), - child: Widget.Box({ - children: [ - MaterialIcon("volume_off", "20px").hook(audio.speaker, (self) => { - const vol = audio.speaker.volume * 100; - const icon = [ - [101, "sound_detection_loud_sound"], - [67, "volume_up"], - [34, "volume_down"], - [1, "volume_mute"], - [0, "volume_off"] - ].find(([threshold]) => Number(threshold) <= vol)?.[1]; - if (audio.speaker.is_muted) self.label = "volume_off"; - else self.label = String(icon!); - self.tooltip_text = `Volume ${Math.floor(vol)}%`; - }), - Widget.Label({ - label: audio.speaker.bind("volume").as((volume) => `${Math.floor(volume * 100)}%`) - }) - ] + child: MaterialIcon("volume_off", "16px").hook(audio.speaker, (self) => { + const vol = audio.speaker.volume * 100; + const icon = [ + [101, "sound_detection_loud_sound"], + [67, "volume_up"], + [34, "volume_down"], + [1, "volume_mute"], + [0, "volume_off"] + ].find(([threshold]) => Number(threshold) <= vol)?.[1]; + if (audio.speaker.is_muted) self.label = "volume_off"; + else self.label = String(icon!); + self.tooltip_text = `Volume ${Math.floor(vol)}%`; }) }) }); } +const Applets = () => + Widget.Box({ + class_name: "bar_applets", + spacing: 5, + children: [volumeIndicator(), Bluetooth(), Wifi()] + }); + const Dot = () => Widget.Label({ class_name: "dot", @@ -536,7 +515,7 @@ function Right() { class_name: "modules-right", hpack: "end", spacing: 8, - children: [volumeIndicator(), KeyboardLayout(), BatteryLabel(), SysTray(), Applets(), Clock(), OpenSideBar()] + children: [KeyboardLayout(), BatteryLabel(), SysTray(), Applets(), Clock(), OpenSideBar()] }); } @@ -545,8 +524,7 @@ export const Bar = async (monitor = 0) => { name: `bar-${monitor}`, class_name: "bar", monitor, - //anchor: ["top", "left", "right"], - anchor: ["bottom", "left", "right"], + anchor: ["top", "left", "right"], exclusivity: "exclusive", child: Widget.CenterBox({ start_widget: Left(), @@ -562,12 +540,10 @@ export const BarCornerTopLeft = (monitor = 0) => name: `bar_corner_tl${monitor}`, class_name: "transparent", layer: "top", - //anchor: ["top", "left"], - anchor: ["bottom", "left"], + anchor: ["top", "left"], exclusivity: "normal", visible: true, - //child: RoundedCorner("top_left", { className: "corner" }), - child: RoundedCorner("bottom_left", { className: "corner" }), + child: RoundedCorner("top_left", { className: "corner" }), setup: enableClickThrough }); @@ -577,11 +553,9 @@ export const BarCornerTopRight = (monitor = 0) => name: `bar_corner_tr${monitor}`, class_name: "transparent", layer: "top", - //anchor: ["top", "right"], - anchor: ["bottom", "right"], + anchor: ["top", "right"], exclusivity: "normal", visible: true, - //child: RoundedCorner("top_right", { className: "corner" }), - child: RoundedCorner("bottom_right", { className: "corner" }), + child: RoundedCorner("top_right", { className: "corner" }), setup: enableClickThrough }); diff --git a/config/ags/modules/cliphist.ts b/config/ags/modules/cliphist.ts new file mode 100644 index 00000000..b70cb612 --- /dev/null +++ b/config/ags/modules/cliphist.ts @@ -0,0 +1,233 @@ +const WINDOW_NAME = "cliphist"; +import popupwindow from "./misc/popupwindow.ts"; +import Gtk from "gi://Gtk?version=3.0"; + +type EntryObject = { + id: string; + content: string; + entry: string; +}; + +const binary_data = /\[\[ binary data (\d+) (KiB|MiB) (\w+) (\d+)x(\d+) \]\]/; + +function ClipHistItem(entry: string) { + let [id, ..._content] = entry.split("\t"); + let content = _content.join(" ").trim(); + const matches = content.match(binary_data); + let _show_image = false; + + let clickCount = 0; + let button = Widget.Button({ + class_name: "clip_container", + child: Widget.Box({ + children: [ + Widget.Label({ + label: id, + class_name: "clip_id", + xalign: 0, + vpack: "center" + }), + Widget.Label({ + label: "・", + class_name: "dot_divider", + xalign: 0, + vpack: "center" + }), + Widget.Label({ + label: content, + class_name: "clip_label", + xalign: 0, + vpack: "center", + truncate: "end" + }) + ] + }) + }); + + function show_image(file: string, width: string | number, height: string | number) { + if (_show_image) return; + const box = button.child; + box.children[2].destroy(); + const icon = Widget.Box({ + vpack: "center", + css: (() => { + const _widthPx = Number(width); + const heightPx = Number(height); + const maxWidth = 400; + const widthPx = (_widthPx / heightPx) * 150; + + let css = `background-image: url("${file}");`; + + if (widthPx > maxWidth) { + const newHeightPx = (150 / widthPx) * maxWidth; + css += `min-height: ${newHeightPx}px; min-width: ${maxWidth}px;`; + } else { + css += `min-height: 150px; min-width: ${widthPx}px;`; + } + + return css; + })(), + class_name: "preview" + }); + // @ts-expect-error + box.children = [...box.children, icon]; + _show_image = true; + } + + function hide_image() { + if (!_show_image) return; + const box = button.child; + box.children[2].destroy(); + const label = Widget.Label({ + label: content, + class_name: "clip_label", + xalign: 0, + vpack: "center", + truncate: "end" + }); + box.children = [...box.children, label]; + _show_image = false; + } + + button.connect("clicked", () => { + clickCount++; + if (clickCount === 2) { + App.closeWindow(WINDOW_NAME); + Utils.execAsync(`${App.configDir}/scripts/cliphist.sh --copy-by-id ${id}`); + clickCount = 0; + } + }); + if (matches) { + // const size = matches[1]; + const format = matches[3]; + const width = matches[4]; + const height = matches[5]; + if (format == "png") { + button.toggleClassName("with_image", true); + button.connect("clicked", () => { + if (!_show_image) { + Utils.execAsync(`${App.configDir}/scripts/cliphist.sh --save-by-id ${id}`) + .then((file) => { + show_image(file, width, height); + Utils.exec(`rm -f /tmp/ags/cliphist/${id}.png`); + }) + .catch(print); + } + }); + } + } + + button.connect("focus-out-event", () => { + clickCount = 0; + }); + + return Widget.Box({ + attribute: { content: content, id: id, hide_image: hide_image, show_image: show_image }, + orientation: Gtk.Orientation.VERTICAL, + visible: true, + children: [ + button, + Widget.Separator({ + class_name: "clip_divider", + orientation: Gtk.Orientation.HORIZONTAL + }) + ] + }); +} + +function ClipHistWidget({ width = 500, height = 500, spacing = 12 }) { + let output: string; + let entries: string[]; + let clipHistItems: EntryObject[]; + + const list = Widget.Box, unknown>({ + vertical: true + }); + + async function repopulate() { + output = await Utils.execAsync(`${App.configDir}/scripts/cliphist.sh --get`) + .then((str) => str) + .catch((err) => { + print(err); + return ""; + }); + entries = output.split("\n").filter((line) => line.trim() !== ""); + clipHistItems = entries.map((entry) => { + let [id, ...content] = entry.split("\t"); + return { id: id.trim(), content: content.join(" ").trim(), entry: entry }; + }); + + const widget_ids = new Set(clipHistItems.map((item) => item.id)); + for (const item of list.children) { + if (!widget_ids.has(item.attribute.id)) { + item.destroy(); + } + } + + const list_ids = new Set(list.children.map((item) => item.attribute.id)); + for (const item of clipHistItems) { + if (!list_ids.has(item.id)) { + const _item = ClipHistItem(item.entry); + list.pack_end(_item, false, false, 0); + } + } + list.children = list.children.sort((a, b) => Number(a.attribute.id) - Number(b.attribute.id)).reverse(); + } + repopulate(); + + const entry = Widget.Entry({ + hexpand: true, + class_name: "cliphistory_entry", + placeholder_text: "Search", + + on_change: ({ text }) => { + const searchText = (text ?? "").toLowerCase(); + list.children.forEach((item) => { + item.visible = item.attribute.content.toLowerCase().includes(searchText); + }); + } + }); + + return Widget.Box({ + vertical: true, + class_name: "cliphistory_box", + margin_top: 14, + margin_right: 14, + children: [ + entry, + Widget.Separator(), + Widget.Scrollable({ + hscroll: "never", + css: `min-width: ${width}px;` + `min-height: ${height}px;`, + child: list + }) + ], + setup: (self) => + self.hook(App, (_, windowName, visible) => { + if (windowName !== WINDOW_NAME) return; + + if (visible) { + repopulate().catch(print); + entry.text = ""; + } else { + for (const item of list.children) { + item.attribute.hide_image(); + } + } + }) + }); +} + +export const cliphist = popupwindow({ + name: WINDOW_NAME, + + class_name: "cliphistory", + visible: false, + keymode: "exclusive", + child: ClipHistWidget({ + width: 500, + height: 500, + spacing: 0 + }), + anchor: ["top", "right"] +}); diff --git a/config/ags/modules/notificationPopups.ts b/config/ags/modules/notificationPopups.ts index 25d23499..51ca7e73 100644 --- a/config/ags/modules/notificationPopups.ts +++ b/config/ags/modules/notificationPopups.ts @@ -279,8 +279,7 @@ export function Notifications(monitor = 0) { monitor, name: `notifications${monitor}`, class_name: "notification-popups", - //anchor: ["top", "right"], - anchor: ["bottom", "right"], + anchor: ["top", "right"], type: Gtk.WindowType.POPUP, child: Widget.Box({ css: "min-width: 2px; min-height: 2px;", diff --git a/config/ags/modules/popups.ts b/config/ags/modules/popups.ts index c7c28454..4fe2ff97 100644 --- a/config/ags/modules/popups.ts +++ b/config/ags/modules/popups.ts @@ -6,6 +6,7 @@ import Revealer from "types/widgets/revealer"; import Box from "types/widgets/box"; import Slider from "types/widgets/slider"; import { Binding } from "types/service"; +import { audio_popup } from "./audio"; const brightnessIcons = [ "brightness_1", @@ -130,6 +131,7 @@ const volume_popup = () => }, (self) => { audio.speaker.connect("notify::volume", (_) => { + if (audio_popup.visible) return; self.attribute.count++; if (self.attribute.count > 0) self.reveal_child = true; Utils.timeout(1500, () => { @@ -152,7 +154,7 @@ export const popups = (monitor = 0) => { children: [_backlight_popup, _volume_popup] }), class_name: "popups", - anchor: ["bottom"], + anchor: ["top"], visible: true }); }; diff --git a/config/ags/modules/sideleft/cliphist.ts b/config/ags/modules/sideleft/cliphist.ts index 2ac575d4..1ae1c591 100644 --- a/config/ags/modules/sideleft/cliphist.ts +++ b/config/ags/modules/sideleft/cliphist.ts @@ -4,7 +4,6 @@ const GLib = imports.gi.GLib; import Box from "types/widgets/box"; import { WINDOW_NAME } from "modules/sideleft/main"; -// Function to get clipboard history async function getClipboardHistory() { try { const process = new Gio.Subprocess({ @@ -22,7 +21,6 @@ async function getClipboardHistory() { } } -// Function to clear clipboard history async function clearClipboardHistory() { try { const process = new Gio.Subprocess({ @@ -33,11 +31,9 @@ async function clearClipboardHistory() { process.init(null); await process.communicate_utf8(null, null); } catch (error) { - // Handle error silently or log to a file if needed } } -// Function to show image preview async function showImagePreview(id, format, width, height) { try { const file = await Utils.execAsync(`${App.configDir}/scripts/cliphist.sh --save-by-id ${id}`); @@ -57,12 +53,10 @@ async function showImagePreview(id, format, width, height) { return css; } catch (error) { - // Handle error silently or log to a file if needed return ''; } } -// Function to create a clipboard history item function ClipHistItem(entry) { const [id, ..._content] = entry.split("\t"); const content = _content.join(" ").trim(); @@ -90,7 +84,6 @@ function ClipHistItem(entry) { clickCount = 0; } } catch (error) { - // Handle error silently or log to a file if needed } }); @@ -108,13 +101,12 @@ function ClipHistItem(entry) { if (!_show_image) { const css = await showImagePreview(id, format, width, height); const box = button.child; - box.children[2].destroy(); // Remove text label + box.children[2].destroy(); const icon = Widget.Box({ vpack: "center", css: css, class_name: "preview" }); - // @ts-expect-error box.children = [...box.children, icon]; _show_image = true; } @@ -135,7 +127,6 @@ function ClipHistItem(entry) { }); } -// Main export function for clipboard history widget export const cliphist = () => { const list = Widget.Box({ vertical: true, vexpand: true }); const loadingIndicator = Widget.Label({ @@ -147,7 +138,7 @@ export const cliphist = () => { async function repopulate() { try { const entries = await getClipboardHistory(); - list.children = []; // Clear loading indicator + list.children = []; if (entries.length > 0) { list.children = entries.map(ClipHistItem); @@ -166,26 +157,24 @@ export const cliphist = () => { hexpand: true, class_name: "cliphistory_entry", placeholder_text: "Search", - on_change: ({ text }) => { + on_change: async ({ text }) => { const searchText = text.toLowerCase(); - list.children.forEach((item) => { - item.visible = item.attribute.content.toLowerCase().includes(searchText); - }); - } - }); - const clearButton = Widget.Button({ - label: "Clear", - class_name: "clear_history_button", - on_clicked: async () => { - await clearClipboardHistory(); - repopulate(); + if (searchText.trim() === '/clear') { + await clearClipboardHistory(); + await repopulate(); + entry.text = ''; + } else { + list.children.forEach((item) => { + item.visible = item.attribute.content.toLowerCase().includes(searchText); + }); + } } }); const searchBox = Widget.Box({ orientation: Gtk.Orientation.HORIZONTAL, - children: [entry, clearButton] + children: [entry] }); return Widget.Box({ diff --git a/config/ags/modules/sideleft/players.ts b/config/ags/modules/sideleft/players.ts index 635b83af..531749cb 100644 --- a/config/ags/modules/sideleft/players.ts +++ b/config/ags/modules/sideleft/players.ts @@ -1,6 +1,7 @@ import { MprisPlayer } from "types/service/mpris.ts"; import Label from "types/widgets/label.ts"; import { MaterialIcon } from "icons.ts"; +import Pango10 from "gi://Pango?version=1.0"; const mpris = await Service.import("mpris"); const players = mpris.bind("players"); @@ -31,7 +32,8 @@ function Player(player: MprisPlayer) { const title = Widget.Label({ class_name: "title", wrap: true, - hpack: "start", + wrap_mode: Pango10.WrapMode.WORD_CHAR, + xalign: 0, label: player.bind("track_title"), use_markup: false }); @@ -39,7 +41,8 @@ function Player(player: MprisPlayer) { const artist = Widget.Label({ class_name: "artist", wrap: true, - hpack: "start", + wrap_mode: Pango10.WrapMode.WORD_CHAR, + xalign: 0, use_markup: false, label: player.bind("track_artists").transform((a) => a.join(", ")) }); diff --git a/config/ags/modules/sideright/system.ts b/config/ags/modules/sideright/system.ts index ea21bc30..d08a5477 100644 --- a/config/ags/modules/sideright/system.ts +++ b/config/ags/modules/sideright/system.ts @@ -3,6 +3,7 @@ import Gtk from "gi://Gtk?version=3.0"; import { Variable as VariableType } from "types/variable"; import backlight_service from "services/backlight.ts"; import { sideright } from "./main"; +import Pango10 from "gi://Pango"; type InfoType = { cpu: string; @@ -111,7 +112,8 @@ const Usage = (name: string, var_name: keyof InfoType, class_name: string | unde const InfoLabel = (name: string, var_name: keyof InfoType, end: string) => { return Widget.Label({ class_name: "info_label", - truncate: "end", + wrap: true, + xalign: 0, hpack: "start", label: usage.bind().as((usage) => `${name}: ${usage[var_name]}${end}`) }); @@ -120,7 +122,9 @@ const InfoLabel = (name: string, var_name: keyof InfoType, end: string) => { const InfoLabelString = (name: string, value: string, end: string) => { return Widget.Label({ class_name: "info_label", - truncate: "end", + wrap: true, + wrap_mode: Pango10.WrapMode.WORD_CHAR, + xalign: 0, hpack: "start", label: `${name}: ${value}${end}` }); @@ -129,7 +133,9 @@ const InfoLabelString = (name: string, value: string, end: string) => { const InfoLabelVariableString = (name: string, value: VariableType, end: string) => { return Widget.Label({ class_name: "info_label", - truncate: "end", + wrap: true, + wrap_mode: Pango10.WrapMode.WORD_CHAR, + xalign: 0, hpack: "start", label: value.bind().as((value) => `${name}: ${value}${end}`) }); diff --git a/config/ags/style-apps.css b/config/ags/style-apps.css index 420dc9c4..9ab4e1fb 100644 --- a/config/ags/style-apps.css +++ b/config/ags/style-apps.css @@ -243,8 +243,13 @@ padding: 0px; } +.emojis .emoji_category:active { + background-color: mix(@onSurfaceVariant, transparent, 0.8); +} + .emojis .emoji_category.active { background-color: @secondaryContainer; + background-image: radial-gradient(circle, @secondaryContainer 10%, transparent 0%); color: @onSecondaryContainer; } @@ -274,7 +279,8 @@ } .emojis .emoji:active { - background-color: @secondaryContainer; + background-color: mix(@onSurfaceVariant, transparent, 0.8); + background-image: radial-gradient(circle, @secondaryContainer 10%, transparent 0%); } .emojis .emoji label { diff --git a/config/ags/style.css b/config/ags/style.css index de5e7b3c..d3fafa83 100644 --- a/config/ags/style.css +++ b/config/ags/style.css @@ -34,6 +34,7 @@ highlight { margin: 0px; border: none; outline: none; + box-shadow: none; transition-property: border-image, background-size, background-image, color, background-color, border-color; transition-duration: 0.3s, 0.3s, 0.3s, 0.2s, 0.2s, 0.2s; @@ -43,7 +44,7 @@ highlight { .corner { background-color: @background; - border-radius: 38px; + border-radius: 34px; } tooltip { @@ -111,22 +112,28 @@ separator { font-size: 16px; color: @onSurface; background: @surfaceContainer; + padding-left: 4px; + padding-right: 4px; } .workspaces * { transition: all 0.35s ease-in-out; - transition-property: background-color, color, min-width; } .workspaces button { padding: 0px 5px; - margin: 4px 3px; + margin: 4px 0px; + margin-right: 3px; border-radius: 16px; border: 0px; } +.workspaces button:last-child { + margin-right: 0px; +} + .workspaces button label { - color: @onSurfaceVariant; + color: @onSurface; font-weight: bold; } @@ -135,9 +142,13 @@ separator { background-color: mix(@onSurface, @surface, 0.85); } +.workspaces button:not(.exists) label { + color: @onSurfaceVariant; + opacity: 0.6; +} + .workspaces button.active { background: @secondaryContainer; - min-width: 40px; } .workspaces button.active label { @@ -214,9 +225,9 @@ window.notification-popups box.notifications { .notification { min-width: 350px; - border-radius: 24px; + border-radius: 20px; padding: 1em; - margin: 1px; + margin-bottom: 2px; background-color: @surfaceContainerLow; } @@ -264,8 +275,10 @@ window.notification-popups box.notifications { * ----------------------------------------------------- */ .cliphistory_box { - border-radius: 24px; + border-radius: 20px; background-color: @background; + border: 1px solid; + border-color: @outlineVariant; } .cliphistory_box separator { @@ -345,31 +358,6 @@ window.notification-popups box.notifications { color: @tertiary; } -.clear_history_button { - background-color: @surfaceContainerHigh; - color: @onSurface; - border: none; - outline: none; - margin: 8px; - border-radius: 100px; - font-size: 13px; -} - -.clear_history_button:hover { - background-color: mix(@onSurface, @surface, 0.92); -} - -.clear_history_button:focus { - background-color: mix(@onSurface, @surface, 0.8); - border: 0px solid; - border: none; - outline: none; -} - -.clear_history_button:active { - background-image: radial-gradient(circle, mix(@onSurface, @surface, 0.78) 10%, transparent 0%); -} - /* ----------------------------------------------------- * Misc * ----------------------------------------------------- */ @@ -385,15 +373,6 @@ window.notification-popups box.notifications { border-radius: 100px; } -.volume_box button { - padding-top: 0px; - padding-bottom: 0px; -} - -.volume_box .icon { - margin-right: 5px; -} - .awesome_icon { font-family: "Font Awesome 6 Free"; } @@ -418,7 +397,8 @@ window.notification-popups box.notifications { background-color: @error; } -.battery.critical label, .battery.critical .icon { +.battery.critical label, +.battery.critical .icon { color: @onError; } @@ -1076,14 +1056,14 @@ switch:checked:active slider { margin-top: 14px; margin-bottom: 14px; background-color: @background; - border-radius: 24px; - border: 2px solid @outlineVariant; + border-radius: 20px; + border: 1px solid @outlineVariant; padding: 5px; } .cheatsheet .category { background-color: @surfaceContainerLow; - border-radius: 17px; + border-radius: 12px; padding-top: 7px; padding-bottom: 7px; box-shadow: 0px 1px 3px rgba(0, 0, 0, 0.12), 0px 1px 2px rgba(0, 0, 0, 0.24); @@ -1262,13 +1242,13 @@ switch:checked:active slider { } .sideleft .player .title { - font-size: 1.2em; + font-size: 20px; margin-left: 10px; color: @foreground; } .sideleft .player .artist { - font-size: 1.1em; + font-size: 18px; margin-left: 10px; color: @foreground; } @@ -1331,7 +1311,7 @@ switch:checked:active slider { /* applauncher */ .sideleft .applauncher_box { - border-radius: 24px; + border-radius: 20px; background-color: @background; margin-right: 12px; } @@ -1560,6 +1540,32 @@ switch:checked:active slider { } } +/* Chatrooms */ +.chats .filled_tonal_button { + padding-left: 24px; + padding-right: 24px; + padding-top: 4px; + padding-bottom: 4px; +} + +.chats .login, +.chats .room { + margin-right: 12px; + margin-top: 10px; +} + +.chats entry { + background-color: transparent; + padding: 5px; + border-radius: 4px; + box-shadow: inset 0 0 0 1px @outline; + transition: box-shadow 0.2s ease-in-out, color 0.2s ease-in-out; + color: @onSurface; +} + +.chats entry:focus { + box-shadow: inset 0 0 0 2px @primary; +} /* ----------------------------------------------------- * Popups @@ -1570,7 +1576,7 @@ switch:checked:active slider { .popups .popup { background-color: @surfaceContainer; - margin-bottom: 14px; + margin-top: 14px; padding: 4px; border-radius: 14px; } @@ -1611,6 +1617,105 @@ switch:checked:active slider { background-color: @primary; } +/* ----------------------------------------------------- + * Audio + * ----------------------------------------------------- */ + +.audio .tabs button { + border-radius: 0px; + border-bottom: 1px solid @surfaceVariant; +} + +.audio .tabs button:hover { + background-color: mix(@onSurfaceVariant, transparent, 0.8); +} + +.audio .tabs button:active { + background-image: radial-gradient(circle, mix(@onSurfaceVariant, transparent, 0.7) 10%, transparent 0%); +} + +.audio .tabs .active button { + border-color: @primary; +} + +.audio .tabs { + margin-bottom: 4px; +} + +.audio_box { + background-color: @background; + border-radius: 20px; + border: 1px solid @outlineVariant; + padding: 6px; + margin-right: 14px; + margin-top: 14px; +} + +.audio .icon { + color: @onSurface; +} + +.audio scrollbar { + opacity: 0; +} + +.audio scrollbar:hover { + opacity: 0.1; +} + +.audio .device { + background-color: @surfaceContainerLow; + border-radius: 6px; + min-width: 300px; + margin-top: 3px; + padding: 10px; + padding-bottom: 6px; +} + +.audio .device:first-child { + border-radius: 14px 14px 6px 6px; + margin-top: 0px; +} + +.audio .device:last-child { + border-radius: 6px 6px 14px 14px; +} + +.audio .device label { + color: @onSurface; +} + +.audio .device button { + padding: 0px; +} + +.audio .device slider { + color: @onPrimary; + background-color: @primary; + background-size: 20px 20px; + min-width: 5px; + min-height: 14px; + border-radius: 100px; + padding: 0px; + background-repeat: no-repeat; + background-position: center; + margin-left: 0px; + margin-right: 0px; + margin-top: -16px; + margin-bottom: -16px; + box-shadow: -4px 0px 0px 1px @surfaceContainerLow, 4px 0px 0px 1px @surfaceContainerLow; +} + +.audio .device trough { + background-color: @secondaryContainer; + min-height: 10px; +} + +.audio .device highlight { + border-radius: 100px 0px 0px 100px; + background-color: @primary; +} + /* ----------------------------------------------------- * Material * ----------------------------------------------------- */