Move some (all) files around
Signed-off-by: Nikolaos Karaolidis <nick@karaolidis.com>
This commit is contained in:
19
hosts/common/user/configs/gui/ags/config/src/index.ts
Normal file
19
hosts/common/user/configs/gui/ags/config/src/index.ts
Normal file
@@ -0,0 +1,19 @@
|
||||
import gtk from 'gi://Gtk?version=3.0';
|
||||
import gdk from 'gi://Gdk';
|
||||
import { range } from 'lib';
|
||||
import themeInit from 'theme';
|
||||
import bar from 'widgets/bar/bar';
|
||||
|
||||
const forMonitors = (widget: (monitor: number) => gtk.Window) => {
|
||||
const n = gdk.Display.get_default()?.get_n_monitors() || 1;
|
||||
return range(n, 0).flatMap(widget);
|
||||
};
|
||||
|
||||
App.config({
|
||||
style: themeInit(),
|
||||
windows: [
|
||||
...forMonitors(bar),
|
||||
]
|
||||
});
|
||||
|
||||
Utils.execAsync('systemd-notify --ready')
|
3
hosts/common/user/configs/gui/ags/config/src/lib.ts
Normal file
3
hosts/common/user/configs/gui/ags/config/src/lib.ts
Normal file
@@ -0,0 +1,3 @@
|
||||
export const range = (length: number, start = 1) => {
|
||||
return Array.from({ length }, (n, i) => i + start);
|
||||
};
|
25
hosts/common/user/configs/gui/ags/config/src/theme.ts
Normal file
25
hosts/common/user/configs/gui/ags/config/src/theme.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
export default () => {
|
||||
const css = `${App.configDir}/theme.css`;
|
||||
const scss = `${App.configDir}/theme.sass`;
|
||||
|
||||
let themeExists = true;
|
||||
|
||||
try {
|
||||
Utils.readFile(scss);
|
||||
Utils.exec(`sassc ${scss} ${css}`);
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
themeExists = false;
|
||||
}
|
||||
|
||||
Utils.monitorFile(
|
||||
`${App.configDir}/theme.sass`,
|
||||
function () {
|
||||
Utils.exec(`sassc ${scss} ${css}`);
|
||||
App.resetCss();
|
||||
App.applyCss(css);
|
||||
},
|
||||
);
|
||||
|
||||
return themeExists ? css : undefined;
|
||||
};
|
@@ -0,0 +1,39 @@
|
||||
import gap from './gap/gap';
|
||||
import launcher from './launcher/launcher';
|
||||
import workspace from './workspace/workspace';
|
||||
import date from './date/date';
|
||||
import systray from './systray/systray';
|
||||
|
||||
export default (monitor: number) => Widget.Window({
|
||||
monitor,
|
||||
class_name: 'bar',
|
||||
name: `bar${monitor}`,
|
||||
exclusivity: 'exclusive',
|
||||
anchor: ['top', 'right', 'left'],
|
||||
child: Widget.CenterBox({
|
||||
class_name: 'widgets',
|
||||
start_widget: Widget.Box({
|
||||
hexpand: true,
|
||||
hpack: 'start',
|
||||
children: [
|
||||
launcher(),
|
||||
gap(),
|
||||
workspace(),
|
||||
],
|
||||
}),
|
||||
center_widget: Widget.Box({
|
||||
hexpand: true,
|
||||
hpack: 'center',
|
||||
children: [
|
||||
date(),
|
||||
],
|
||||
}),
|
||||
end_widget: Widget.Box({
|
||||
hexpand: true,
|
||||
hpack: 'end',
|
||||
children: [
|
||||
systray(),
|
||||
],
|
||||
}),
|
||||
}),
|
||||
});
|
@@ -0,0 +1,10 @@
|
||||
const icon = () => Widget.Icon({
|
||||
class_name: 'icon',
|
||||
icon: 'edit-paste-symbolic',
|
||||
});
|
||||
|
||||
export default () => Widget.EventBox({
|
||||
class_name: 'clipboard',
|
||||
child: icon(),
|
||||
onPrimaryClick: () => Utils.execAsync('bash -c "cliphist list | rofi -cache-dir $XDG_CACHE_HOME/rofi -dmenu -display-columns 2 | cliphist decode | wl-copy"'),
|
||||
});
|
@@ -0,0 +1,18 @@
|
||||
import glib from 'gi://GLib';
|
||||
|
||||
const clock = Variable(glib.DateTime.new_now_local(), {
|
||||
poll: [1000, () => glib.DateTime.new_now_local()]
|
||||
});
|
||||
|
||||
const time = Utils.derive([clock], (c) => c.format('%H:%M - %A, %d %B %Y') || '');
|
||||
|
||||
const label = () => Widget.Label({
|
||||
class_name: 'label',
|
||||
justification: 'center',
|
||||
label: time.bind(),
|
||||
});
|
||||
|
||||
export default () => Widget.EventBox({
|
||||
class_name: 'date',
|
||||
child: label(),
|
||||
});
|
@@ -0,0 +1,3 @@
|
||||
export default () => Widget.Box({
|
||||
class_name: 'gap',
|
||||
});
|
@@ -0,0 +1,10 @@
|
||||
const icon = () => Widget.Icon({
|
||||
class_name: 'icon',
|
||||
icon: 'nix-snowflake-symbolic',
|
||||
});
|
||||
|
||||
export default () => Widget.EventBox({
|
||||
class_name: 'launcher',
|
||||
child: icon(),
|
||||
onPrimaryClick: () => Utils.execAsync('bash -c "rofi -cache-dir $XDG_CACHE_HOME/rofi -show drun"'),
|
||||
});
|
@@ -0,0 +1,16 @@
|
||||
import gdk from 'gi://Gdk';
|
||||
|
||||
const systemtray = await Service.import('systemtray');
|
||||
|
||||
const systrayItem = item => Widget.EventBox({
|
||||
class_name: 'item',
|
||||
tooltip_markup: item.bind('tooltip_markup'),
|
||||
child: Widget.Icon({ class_name: 'icon' }).bind('icon', item, 'icon'),
|
||||
onPrimaryClick: (_, event: gdk.Event) => item.activate(event),
|
||||
onSecondaryClick: (_, event: gdk.Event) => item.openMenu(event),
|
||||
});
|
||||
|
||||
export default () => Widget.Box({
|
||||
class_name: 'systray',
|
||||
children: systemtray.bind('items').as(i => i.map(systrayItem))
|
||||
});
|
@@ -0,0 +1,23 @@
|
||||
import { range } from 'lib';
|
||||
|
||||
const hyprland = await Service.import('hyprland');
|
||||
const dispatch = ws => hyprland.messageAsync(`dispatch workspace ${ws}`);
|
||||
|
||||
const workspaceButton = (i: number) => Widget.Label({
|
||||
class_name: 'button',
|
||||
attribute: i,
|
||||
vpack: 'center',
|
||||
setup: self => self.hook(hyprland, () => {
|
||||
self.toggleClassName('active', hyprland.active.workspace.id === i);
|
||||
self.toggleClassName('occupied', (hyprland.getWorkspace(i)?.windows || 0) > 0);
|
||||
}),
|
||||
});
|
||||
|
||||
export default () => Widget.EventBox({
|
||||
class_name: 'workspace',
|
||||
onScrollUp: () => dispatch('e-1'),
|
||||
onScrollDown: () => dispatch('e+1'),
|
||||
child: Widget.Box({
|
||||
children: range(10).map(workspaceButton),
|
||||
}),
|
||||
});
|
Reference in New Issue
Block a user