nixos-configs/devices/wim/config/ags/js/applauncher/app-item.js

75 lines
1.8 KiB
JavaScript
Raw Normal View History

import App from 'resource:///com/github/Aylur/ags/app.js';
import Hyprland from 'resource:///com/github/Aylur/ags/service/hyprland.js';
import { Box, Icon, Label } from 'resource:///com/github/Aylur/ags/widget.js';
import { lookUpIcon } from 'resource:///com/github/Aylur/ags/utils.js';
import EventBox from '../misc/cursorbox.js';
2023-12-18 18:00:30 -05:00
/**
* @param {import('types/service/applications.js').Application} app
*/
export default (app) => {
2023-12-18 18:00:30 -05:00
const icon = Icon({ size: 42 });
const iconString = app.app.get_string('Icon');
if (app.icon_name) {
if (lookUpIcon(app.icon_name)) {
icon.icon = app.icon_name;
}
else if (iconString && iconString !== 'nix-snowflake') {
icon.icon = iconString;
}
else {
icon.icon = '';
}
}
const textBox = Box({
vertical: true,
vpack: 'start',
children: [
Label({
class_name: 'title',
label: app.name,
xalign: 0,
truncate: 'end',
}),
Label({
class_name: 'description',
label: app.description || '',
wrap: true,
xalign: 0,
justification: 'left',
}),
Label(),
],
});
return EventBox({
2023-12-07 01:18:47 -05:00
hexpand: true,
class_name: 'app',
2023-12-18 18:00:30 -05:00
attribute: { app },
2023-12-18 18:00:30 -05:00
onPrimaryClickRelease: (self) => {
App.closeWindow('applauncher');
2023-12-18 18:00:30 -05:00
Hyprland.sendMessage(`dispatch exec sh -c
${self.attribute.app.executable}`);
++self.attribute.app.frequency;
},
child: Box({
children: [
icon,
textBox,
],
}),
});
};