From 3e0389bcaccbec31c8fc893f5bf150d1b48f54bd Mon Sep 17 00:00:00 2001 From: S4NKALP Date: Thu, 4 Jul 2024 05:19:46 +0545 Subject: [PATCH] update --- config/ags/.eslintrc.yml | 59 +++++++++ config/ags/apps/settings/wallpapers.ts | 16 ++- config/ags/main.ts | 5 - config/ags/modules/musicplayer.ts | 112 ++++++++++++++++++ config/ags/style.css | 4 +- config/ags/wallpaper | 1 - .../assets}/svg/brightness-onPrimary.svg | 0 .../assets}/svg/dark-onPrimary.svg | 0 8 files changed, 180 insertions(+), 17 deletions(-) create mode 100644 config/ags/.eslintrc.yml create mode 100644 config/ags/modules/musicplayer.ts delete mode 120000 config/ags/wallpaper rename config/{ags => hypr/assets}/svg/brightness-onPrimary.svg (100%) rename config/{ags => hypr/assets}/svg/dark-onPrimary.svg (100%) diff --git a/config/ags/.eslintrc.yml b/config/ags/.eslintrc.yml new file mode 100644 index 00000000..1dd5a5b0 --- /dev/null +++ b/config/ags/.eslintrc.yml @@ -0,0 +1,59 @@ +env: + es2022: true +extends: + - eslint:recommended + - plugin:@typescript-eslint/recommended +parser: "@typescript-eslint/parser" +parserOptions: + ecmaVersion: 2022 + sourceType: module + project: ./tsconfig.json + warnOnUnsupportedTypeScriptVersion: false +root: true +ignorePatterns: + - types/ +plugins: + - "@typescript-eslint" +rules: + "@typescript-eslint/ban-ts-comment": + - "off" + "@typescript-eslint/no-non-null-assertion": + - "off" + # "@typescript-eslint/no-explicit-any": + # - "off" + "@typescript-eslint/no-unused-vars": + - error + - varsIgnorePattern: (^unused|_$) + argsIgnorePattern: ^(unused|_) + "@typescript-eslint/no-empty-interface": + - "off" + indent: + - error + - 2 + - SwitchCase: 1 + linebreak-style: + - error + - unix + quotes: + - error + - single + - avoidEscape: true + semi: + - error + - never + no-trailing-spaces: + - error +globals: + pkg: readonly + ags: readonly + ARGV: readonly + imports: readonly + print: readonly + console: readonly + logError: readonly + + App: writable + Utils: writable + Widget: writable + Service: writable + Variable: writable diff --git a/config/ags/apps/settings/wallpapers.ts b/config/ags/apps/settings/wallpapers.ts index 8ccc347b..8fae952d 100644 --- a/config/ags/apps/settings/wallpapers.ts +++ b/config/ags/apps/settings/wallpapers.ts @@ -79,7 +79,7 @@ const Wallpaper = (image: string, name: string) => Widget.Button({ vpack: "center", class_name: "image", setup(self) { - const cache_file = `${GLib.get_home_dir()}/.cache/thumbnails/wallpaper/${name}`; + const cache_file = `${GLib.get_home_dir()}/.cache/thumbnails/wallpapers/${name}`; Utils.readFileAsync(cache_file) .catch(() => { Utils.execAsync(`magick ${image} -resize x32 -gravity Center -extent 1:1 ${cache_file}`) @@ -113,15 +113,14 @@ const Wallpaper = (image: string, name: string) => Widget.Button({ }); function CacheThumbnails() { - Utils.execAsync(`mkdir -p ${GLib.get_home_dir()}/.cache/thumbnails/wallpaper`) + Utils.execAsync(`mkdir -p ${GLib.get_home_dir()}/.cache/thumbnails/wallpapers`) .catch(print) - const link_directory = `${App.configDir}/wallpaper`; - const original_directory = `${GLib.get_home_dir()}/wallpaper`; + const original_directory = `${GLib.get_home_dir()}/Pictures/wallpapers`; const extensions = [".jpg", ".jpeg", ".png"]; - const fileList = listFilesByExtensions(link_directory, extensions); + const fileList = listFilesByExtensions(original_directory, extensions); fileList.forEach((value, index) => { const path = `${original_directory}/${value}` - const cache_file = `${GLib.get_home_dir()}/.cache/thumbnails/wallpaper/${value}`; + const cache_file = `${GLib.get_home_dir()}/.cache/thumbnails/wallpapers/${value}`; Utils.idle(() => { Utils.readFileAsync(cache_file) .catch(() => { @@ -135,12 +134,11 @@ function CacheThumbnails() { CacheThumbnails() const WallpaperList = () => { - Utils.execAsync(`mkdir -p ${GLib.get_home_dir()}/.cache/thumbnails/wallpaper`) + Utils.execAsync(`mkdir -p ${GLib.get_home_dir()}/.cache/thumbnails/wallpapers`) .then(); - const link_directory = `${App.configDir}/wallpaper`; const original_directory = `${GLib.get_home_dir()}/Pictures/wallpapers`; const extensions = [".jpg", ".jpeg", ".png"]; - let fileList = listFilesByExtensions(link_directory, extensions); + let fileList = listFilesByExtensions(original_directory, extensions); let [l_fileList, r_fileList] = splitListInHalf(fileList); const box = Widget.Box({ vertical: false, diff --git a/config/ags/main.ts b/config/ags/main.ts index a5161d7b..6cbc33a4 100644 --- a/config/ags/main.ts +++ b/config/ags/main.ts @@ -73,11 +73,6 @@ Utils.monitorFile( ReloadCSS ) -Utils.monitorFile( - `${GLib.get_home_dir()}/.cache/material/colors.json`, - ReloadCSS -) - Utils.monitorFile( `${GLib.get_home_dir()}/.config/gtk-3.0/gtk.css`, ReloadGtkCSS diff --git a/config/ags/modules/musicplayer.ts b/config/ags/modules/musicplayer.ts new file mode 100644 index 00000000..009cf69a --- /dev/null +++ b/config/ags/modules/musicplayer.ts @@ -0,0 +1,112 @@ +const WINDOW_NAME = "musicplayer"; +import popupwindow from './misc/popupwindow.ts'; +import Box from 'types/widgets/box.js'; +import Gtk from "gi://Gtk?version=3.0"; +import GLib from "gi://GLib?version=2.0"; + +type Track = { + id: string; + title: string; + artist: string; + url: string; // Assuming we use URLs for identification, but not playback. +}; + +function MusicPlayerItem(track: Track) { + let button = Widget.Button({ + class_name: "track_container", + child: Widget.Label({ + label: `${track.title} - ${track.artist}`, + class_name: "track_label", + xalign: 0, + vpack: "center", + truncate: "end", + }) + }); + + button.connect('clicked', () => { + playTrack(track); // Function to handle playback + }); + + return Widget.Box({ + orientation: Gtk.Orientation.VERTICAL, + children: [ + button, + Widget.Separator({ + orientation: Gtk.Orientation.HORIZONTAL + }) + ] + }); +} + +async function playTrack(track: Track) { + try { + // Placeholder for playing audio via libcanberra or other suitable GTK audio APIs + GLib.spawn_command_line_async(`canberra-gtk-play -i audio-file-id`); + } catch (error) { + console.error(`Error playing track: ${error}`); + } +} + +function MusicPlayerWidget({ width = 500, height = 500, spacing = 12 }) { + let tracks: Track[] = [ + { id: "1", title: "Track 1", artist: "Artist 1", url: "1" }, + { id: "2", title: "Track 2", artist: "Artist 2", url: "2" }, + { id: "3", title: "Track 3", artist: "Artist 3", url: "3" } + // Add more tracks as needed + ]; + + let widgets: Box[] = tracks.map(track => MusicPlayerItem(track)); + + const list = Widget.Box({ + vertical: true, + spacing, + children: widgets + }); + + const entry = Widget.Entry({ + hexpand: true, + class_name: "musicplayer_entry", + placeholder_text: "Search", + + on_change: ({ text }) => widgets.forEach(item => { + item.visible = item.attribute.content.match(text ?? "") + }), + }); + + return Widget.Box({ + vertical: true, + class_name: "musicplayer_box", + margin_top: 14, + margin_right: 14, + children: [ + entry, + 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) { + entry.text = ""; + } + }), + }); +} + +export const musicplayer = popupwindow({ + name: WINDOW_NAME, + class_name: "musicplayer", + visible: false, + keymode: "exclusive", + child: MusicPlayerWidget({ + width: 500, + height: 500, + spacing: 0, + }), + anchor: ["bottom", "right"] +}); diff --git a/config/ags/style.css b/config/ags/style.css index 584c412b..be1ef747 100644 --- a/config/ags/style.css +++ b/config/ags/style.css @@ -708,7 +708,7 @@ window.notification-popups box.notifications { } .system_scale.backlight slider { - background-image: -gtk-scaled(url("svg/brightness-onPrimary.svg")); + background-image: -gtk-scaled(url("../hypr/assets/svg/brightness-onPrimary.svg")); } .system_scale.backlight { @@ -716,7 +716,7 @@ window.notification-popups box.notifications { } .system_scale.brightness slider { - background-image: -gtk-scaled(url("svg/dark-onPrimary.svg")); + background-image: -gtk-scaled(url("../hypr/assets/svg/dark-onPrimary.svg")); } .system_scale { diff --git a/config/ags/wallpaper b/config/ags/wallpaper deleted file mode 120000 index 43a08017..00000000 --- a/config/ags/wallpaper +++ /dev/null @@ -1 +0,0 @@ -/home/sankalp/Pictures/wallpapers \ No newline at end of file diff --git a/config/ags/svg/brightness-onPrimary.svg b/config/hypr/assets/svg/brightness-onPrimary.svg similarity index 100% rename from config/ags/svg/brightness-onPrimary.svg rename to config/hypr/assets/svg/brightness-onPrimary.svg diff --git a/config/ags/svg/dark-onPrimary.svg b/config/hypr/assets/svg/dark-onPrimary.svg similarity index 100% rename from config/ags/svg/dark-onPrimary.svg rename to config/hypr/assets/svg/dark-onPrimary.svg