[Meson] Prepare
This commit is contained in:
		| @@ -1,4 +1,4 @@ | ||||
| import { bind, readFile, Variable, writeFile } from "astal"; | ||||
| import { bind, readFile, writeFile } from "astal"; | ||||
| import { Gtk } from "astal/gtk4"; | ||||
| import AstalBluetooth from "gi://AstalBluetooth"; | ||||
| import BTDevice from "./Device"; | ||||
| @@ -74,7 +74,7 @@ const openBTPicker = () => { | ||||
| }; | ||||
|  | ||||
| const BluetoothPickerList = () => { | ||||
|     let btEnableState = readFile("./btconf") === "true" ? true : false; | ||||
|     let btEnableState = readFile(`${DATADIR}./btconf`) === "true" ? true : false; | ||||
|     bt.adapter.set_powered(btEnableState); | ||||
|  | ||||
|     const updateState = () => { | ||||
|   | ||||
| @@ -3,6 +3,7 @@ import { bind, GObject } from "astal"; | ||||
| import AstalHyprland from "gi://AstalHyprland"; | ||||
| import { Gtk } from "astal/gtk4"; | ||||
|  | ||||
| const hypr = AstalHyprland.get_default(); | ||||
| const SYNC = GObject.BindingFlags.SYNC_CREATE; | ||||
|  | ||||
| const SysTray = () => { | ||||
| @@ -48,8 +49,6 @@ const SysTray = () => { | ||||
| }; | ||||
|  | ||||
| const Workspace = () => { | ||||
|     const hypr = AstalHyprland.get_default(); | ||||
|  | ||||
|     return ( | ||||
|         <box> | ||||
|             {bind(hypr, "workspaces").as(wss => | ||||
| @@ -61,9 +60,9 @@ const Workspace = () => { | ||||
|                             cssClasses={bind(hypr, "focusedWorkspace").as(fw => | ||||
|                                 ws === fw | ||||
|                                     ? [ | ||||
|                                           "focused-workspace-button", | ||||
|                                           "workspace-button", | ||||
|                                       ] | ||||
|                                         "focused-workspace-button", | ||||
|                                         "workspace-button", | ||||
|                                     ] | ||||
|                                     : ["workspace-button"], | ||||
|                             )} | ||||
|                             onButtonPressed={() => ws.focus()} | ||||
| @@ -80,88 +79,13 @@ const Workspace = () => { | ||||
|  * displaying all available clients | ||||
|  */ | ||||
| const ActiveWindow = () => { | ||||
|     const hypr = AstalHyprland.get_default(); | ||||
|     const focused = bind(hypr, "focusedClient"); | ||||
|  | ||||
|     const WindowPopover = (): Gtk.Popover => { | ||||
|         // Set up boxes + Popover | ||||
|         const clients = new Map<string, Gtk.Button>(); | ||||
|         const popover = new Gtk.Popover(); | ||||
|         const popoverBox = new Gtk.Box({ | ||||
|             orientation: Gtk.Orientation.VERTICAL, | ||||
|         }); | ||||
|  | ||||
|         const widgetTitle = new Gtk.Label({ | ||||
|             cssClasses: ["title-2"], | ||||
|             label: "Available Windows", | ||||
|         }); | ||||
|  | ||||
|         popoverBox.append(widgetTitle); | ||||
|  | ||||
|         const seaparator = new Gtk.Separator({ | ||||
|             marginTop: 5, | ||||
|             marginBottom: 10, | ||||
|         }); | ||||
|  | ||||
|         popoverBox.append(seaparator); | ||||
|  | ||||
|         const addClient = (client: AstalHyprland.Client) => { | ||||
|             const clientBox = new Gtk.Box(); | ||||
|  | ||||
|             // Workspace description | ||||
|             const descWS = new Gtk.Label({ label: "(WS " }); | ||||
|  | ||||
|             // Workpsace information | ||||
|             const workspace = new Gtk.Label(); | ||||
|             client.workspace.bind_property("name", workspace, "label", SYNC); | ||||
|  | ||||
|             const windowClassDesc = new Gtk.Label({ label: ") [" }); | ||||
|  | ||||
|             const windowClass = new Gtk.Label(); | ||||
|             windowClass.label = client.get_initial_class(); | ||||
|  | ||||
|             const titleDesc = new Gtk.Label({ label: "] " }); | ||||
|             titleDesc.set_margin_end(2); | ||||
|  | ||||
|             const title = new Gtk.Label(); | ||||
|             client.bind_property("title", title, "label", SYNC); | ||||
|  | ||||
|             clientBox.append(descWS); | ||||
|             clientBox.append(workspace); | ||||
|             clientBox.append(windowClassDesc); | ||||
|             clientBox.append(windowClass); | ||||
|             clientBox.append(titleDesc); | ||||
|             clientBox.append(title); | ||||
|  | ||||
|             const button = new Gtk.Button(); | ||||
|             button.connect( 'clicked', () => { | ||||
|                 client.workspace.focus(); | ||||
|             } ); | ||||
|             button.set_child(clientBox); | ||||
|  | ||||
|             popoverBox.append(button); | ||||
|  | ||||
|             clients.set(client.get_address(), button); | ||||
|         }; | ||||
|  | ||||
|         // Populate with already added clients | ||||
|         const c = hypr.get_clients(); | ||||
|         for (let index = 0; index < c.length; index++) { | ||||
|             addClient(c[index]); | ||||
|         } | ||||
|  | ||||
|         hypr.connect("client-added", (_, client) => { | ||||
|             addClient(client); | ||||
|         }); | ||||
|  | ||||
|         hypr.connect("client-removed", (_, client) => { | ||||
|             const c = clients.get(client); | ||||
|             if (c) { | ||||
|                 popoverBox.remove(c); | ||||
|                 c.run_dispose(); | ||||
|                 clients.delete(client); | ||||
|             } | ||||
|         }); | ||||
|         const popoverBox = WindowPopoverBox(); | ||||
|  | ||||
|         popover.set_child(popoverBox); | ||||
|         return popover; | ||||
| @@ -177,19 +101,37 @@ const ActiveWindow = () => { | ||||
|             <button | ||||
|                 onClicked={() => windowPopover.popup()} | ||||
|                 cssClasses={["bar-button"]} | ||||
|             > | ||||
|                 {focused.as( | ||||
|                     client => | ||||
|                         client && ( | ||||
|                             <label label={bind(client, "title").as(String)} /> | ||||
|                         ), | ||||
|                 )} | ||||
|             </button> | ||||
|                 child={ | ||||
|                     focused.as( | ||||
|                         client => | ||||
|                             client && ( | ||||
|                                 <label label={bind(client, "title").as(String)} /> | ||||
|                             ), | ||||
|                     ) | ||||
|                 }></button> | ||||
|             {windowPopover} | ||||
|         </box> | ||||
|         </box > | ||||
|     ); | ||||
| }; | ||||
|  | ||||
| const WindowPopoverBox = () => { | ||||
|     return <box vertical> | ||||
|         <label label={"Available Windows"} cssClasses={['title-2']}></label> | ||||
|         <Gtk.Separator marginTop={5} marginBottom={5}></Gtk.Separator> | ||||
|         <box vertical> | ||||
|             {bind(hypr, 'clients').as(clients => { | ||||
|                 return clients.map(client => { | ||||
|                     return <box> | ||||
|                         <label label={bind(client, 'workspace').as(w => `(WS ${w})`)}></label> | ||||
|                         <label label={bind(client, 'initialClass').as(c => `[${c}]`)}></label> | ||||
|                         <label label={bind(client, 'title')}></label> | ||||
|                     </box> | ||||
|                 }) | ||||
|             })} | ||||
|         </box> | ||||
|     </box> | ||||
| } | ||||
|  | ||||
| export default { | ||||
|     Workspace, | ||||
|     ActiveWindow, | ||||
|   | ||||
							
								
								
									
										1
									
								
								config/astal/env.d.ts
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										1
									
								
								config/astal/env.d.ts
									
									
									
									
										vendored
									
									
								
							| @@ -1,4 +1,5 @@ | ||||
| declare const SRC: string | ||||
| declare const DATADIR: string | ||||
|  | ||||
| declare module "inline:*" { | ||||
|     const content: string | ||||
|   | ||||
							
								
								
									
										27
									
								
								config/astal/meson.build
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										27
									
								
								config/astal/meson.build
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,27 @@ | ||||
| pkgdatadir = get_option('prefix') / get_option('datadir') / meson.project_name() | ||||
| main = meson.project_name() + '.wrapped' | ||||
|  | ||||
| custom_target( | ||||
|   command: [ | ||||
|     find_program('ags'), | ||||
|     'bundle', | ||||
|     '--root', meson.project_source_root(), | ||||
|     meson.project_source_root() / 'app.ts', | ||||
|     main, | ||||
|   ], | ||||
|   output: main, | ||||
|   input: files('app.ts'), | ||||
|   install: true, | ||||
|   install_dir: pkgdatadir, | ||||
| ) | ||||
|  | ||||
| configure_file( | ||||
|   input: files('wrapper.sh'), | ||||
|   output: meson.project_name(), | ||||
|   configuration: { | ||||
|     'MAIN_PROGRAM': pkgdatadir / main, | ||||
|     'LAYER_SHELL_LIBDIR': dependency('gtk4-layer-shell-0').get_variable('libdir'), | ||||
|   }, | ||||
|   install: true, | ||||
|   install_dir: get_option('prefix') / get_option('bindir'), | ||||
| ) | ||||
							
								
								
									
										2789
									
								
								config/astal/runner
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										2789
									
								
								config/astal/runner
									
									
									
									
									
										Executable file
									
								
							
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							
							
								
								
									
										2
									
								
								config/astal/wrapper.sh
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										2
									
								
								config/astal/wrapper.sh
									
									
									
									
									
										Executable file
									
								
							| @@ -0,0 +1,2 @@ | ||||
| #!/bin/bash | ||||
| LD_PRELOAD="@LAYER_SHELL_LIBDIR@/libgtk4-layer-shell.so" @MAIN_PROGRAM@ $@ | ||||
		Reference in New Issue
	
	Block a user