2023-11-13 15:19:49 -05:00
|
|
|
import App from 'resource:///com/github/Aylur/ags/app.js';
|
2023-11-21 01:29:46 -05:00
|
|
|
import Hyprland from 'resource:///com/github/Aylur/ags/service/hyprland.js';
|
|
|
|
|
2023-11-25 13:10:36 -05:00
|
|
|
import { Box, Button, CenterBox, Icon, Label } from 'resource:///com/github/Aylur/ags/widget.js';
|
2023-11-13 15:19:49 -05:00
|
|
|
import { lookUpIcon } from 'resource:///com/github/Aylur/ags/utils.js';
|
|
|
|
|
|
|
|
import Separator from '../misc/separator.js';
|
|
|
|
|
2023-11-25 13:10:36 -05:00
|
|
|
const ENTRY_SPACING = 16;
|
2023-11-13 15:19:49 -05:00
|
|
|
|
2023-11-21 01:29:46 -05:00
|
|
|
export default (app) => {
|
|
|
|
const title = Label({
|
2023-11-13 15:19:49 -05:00
|
|
|
class_name: 'title',
|
|
|
|
label: app.name,
|
|
|
|
xalign: 0,
|
|
|
|
vpack: 'center',
|
|
|
|
truncate: 'end',
|
|
|
|
});
|
|
|
|
|
2023-11-21 01:29:46 -05:00
|
|
|
const description = Label({
|
2023-11-13 15:19:49 -05:00
|
|
|
class_name: 'description',
|
|
|
|
label: app.description || '',
|
|
|
|
wrap: true,
|
|
|
|
xalign: 0,
|
|
|
|
justification: 'left',
|
|
|
|
vpack: 'center',
|
|
|
|
});
|
|
|
|
|
2023-11-21 01:29:46 -05:00
|
|
|
const icon = Icon({
|
|
|
|
icon: lookUpIcon(app.icon_name) ?
|
|
|
|
app.icon_name :
|
|
|
|
app.app.get_string('Icon') === 'nix-snowflake' ?
|
|
|
|
'' :
|
|
|
|
app.app.get_string('Icon'),
|
2023-11-13 15:19:49 -05:00
|
|
|
size: 42,
|
|
|
|
});
|
|
|
|
|
2023-11-25 13:10:36 -05:00
|
|
|
const textBox = CenterBox({
|
2023-11-13 15:19:49 -05:00
|
|
|
vertical: true,
|
2023-11-25 13:10:36 -05:00
|
|
|
start_widget: title,
|
|
|
|
center_widget: description,
|
|
|
|
end_widget: Separator(ENTRY_SPACING, { vertical: true }),
|
2023-11-13 15:19:49 -05:00
|
|
|
});
|
|
|
|
|
2023-11-21 01:29:46 -05:00
|
|
|
|
|
|
|
return Button({
|
2023-11-13 15:19:49 -05:00
|
|
|
class_name: 'app',
|
2023-11-21 01:29:46 -05:00
|
|
|
|
|
|
|
setup: (self) => {
|
|
|
|
self.app = app;
|
|
|
|
},
|
|
|
|
|
2023-11-13 15:19:49 -05:00
|
|
|
on_clicked: () => {
|
|
|
|
App.closeWindow('applauncher');
|
|
|
|
Hyprland.sendMessage(`dispatch exec sh -c ${app.executable}`);
|
|
|
|
++app.frequency;
|
|
|
|
},
|
2023-11-21 01:29:46 -05:00
|
|
|
|
|
|
|
child: Box({
|
|
|
|
children: [
|
|
|
|
icon,
|
|
|
|
Separator(ENTRY_SPACING),
|
|
|
|
textBox,
|
|
|
|
],
|
2023-11-13 15:19:49 -05:00
|
|
|
}),
|
|
|
|
});
|
|
|
|
};
|