Add ags workspaces

Signed-off-by: Nikolaos Karaolidis <nick@karaolidis.com>
This commit is contained in:
2024-07-01 22:59:36 +03:00
parent e5bac20f7d
commit 30d56ebf00
16 changed files with 66 additions and 6 deletions

View File

@@ -12,7 +12,7 @@ pkgs.stdenv.mkDerivation {
];
buildPhase = ''
bun build $src/index.ts --outfile=index.js \
bun build $src/src/index.ts --outfile=index.js \
--external="file://$src/*" \
--external="gi://*"
'';

View File

@@ -1,4 +1,5 @@
import date from './date/date';
import workspace from './workspace/workspace';
export default (monitor: number) => Widget.Window({
monitor,
@@ -11,13 +12,15 @@ export default (monitor: number) => Widget.Window({
// eslint-disable-next-line @typescript-eslint/naming-convention
startWidget: Widget.Box({
hexpand: true,
children: [],
children: [
workspace(),
],
}),
// eslint-disable-next-line @typescript-eslint/naming-convention
centerWidget: Widget.Box({
hpack: 'center',
children: [
date()
date(),
],
}),
// eslint-disable-next-line @typescript-eslint/naming-convention

View File

@@ -4,7 +4,7 @@ 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, %e %B %Y') || '');
const time = Utils.derive([clock], (c) => c.format('%H:%M - %A, %d %B %Y') || '');
export default () => Widget.Label({
class_name: 'label',

View File

@@ -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),
}),
});

View File

@@ -9,7 +9,7 @@
"checkJs": true,
"strict": true,
"noImplicitAny": false,
"baseUrl": ".",
"baseUrl": "./src",
"typeRoots": [
"./types",
],

View File

@@ -2,7 +2,7 @@
let
hmConfig = config.home-manager.users."${user.name}";
agsConfig = (import ./src { inherit pkgs; });
agsConfig = (import ./config { inherit pkgs; });
in
{
home-manager.users."${user.name}" = {

View File

@@ -3,3 +3,28 @@
.label
color: {{colors.on_surface.default.hex}}
font-size: {{custom.font_size}}pt;
.workspace
min-height: {{custom.font_size}}pt;
.button
font-size: 0;
transition: .5s;
margin: 0 .3 * {{custom.padding}}pt;
background-color: {{colors.surface_variant.default.hex}};
min-width: .4 * {{custom.font_size}}pt;
min-height: .4 * {{custom.font_size}}pt;
border-radius: .5 * {{custom.font_size}}pt;
&.occupied
background-color: {{colors.on_surface.default.hex}}
min-width: .6 * {{custom.font_size}}pt;
min-height: .6 * {{custom.font_size}}pt;
border-radius: .5 * {{custom.font_size}}pt;
&.active
background-color: {{colors.primary.default.hex}}
min-width: 1.67 * {{custom.font_size}}pt;
min-height: {{custom.font_size}}pt;
border-radius: .4 * {{custom.font_size}}pt;

View File

@@ -56,6 +56,7 @@ in
opacity_hex = builtins.toString (percentageToHex hmConfig.theme.opacity);
opacity_shadow = builtins.toString (hmConfig.theme.opacity * .75);
opacity_shadow_hex = builtins.toString (percentageToHex (hmConfig.theme.opacity * .75));
font_size = builtins.toString hmConfig.theme.font.size;
};
};