Skip to content

Commit 0d0a5e7

Browse files
authored
Merge pull request #642 from simonjones49/khal-agenda
initial release khal-agenda
2 parents ff42614 + 6256530 commit 0d0a5e7

5 files changed

Lines changed: 162 additions & 0 deletions

File tree

Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
import QtQuick
2+
import QtQuick.Controls
3+
import QtQuick.Layouts
4+
import Quickshell
5+
import Quickshell.Io
6+
import qs.Commons
7+
import qs.Modules.DesktopWidgets
8+
import qs.Widgets
9+
10+
DraggableDesktopWidget {
11+
id: root
12+
property var pluginApi: null
13+
14+
// Updated dimensions
15+
readonly property real _width: Math.round(320 * widgetScale)
16+
readonly property real _height: Math.round(200 * widgetScale)
17+
18+
implicitWidth: _width
19+
implicitHeight: _height
20+
21+
property string calendarVal: ""
22+
23+
// Main data process
24+
Process {
25+
id: calProc
26+
command: ["sh", "-c", "khal list today 7d --format '{start-end-time-style} {title}' --day-format '{name}, {date}'"]
27+
running: root.pluginApi !== null
28+
stdout: StdioCollector {
29+
onTextChanged: root.calendarVal = text.trim().replace(/\n\s*\n/g, '\n')
30+
}
31+
}
32+
33+
// Universal terminal launcher (Handles -e and -- syntax) but has the class for kitty alone
34+
Process {
35+
id: openIkhal
36+
command: [
37+
"sh", "-c",
38+
"for term in xdg-terminal-exec kitty alacritty foot gnome-terminal konsole st xterm; do " +
39+
"if command -v $term >/dev/null 2>&1; then " +
40+
"if [ \"$term\" = \"kitty\" ]; then " +
41+
"exec kitty --class khal -e ikhal; " +
42+
"else " +
43+
"exec $term -e ikhal 2>/dev/null || exec $term -- ikhal; " +
44+
"fi; break; fi; done"
45+
]
46+
}
47+
48+
// Refresh every minute
49+
Timer {
50+
interval: 60000
51+
running: root.pluginApi !== null
52+
repeat: true
53+
onTriggered: {
54+
calProc.running = false
55+
calProc.running = true
56+
}
57+
}
58+
59+
Rectangle {
60+
anchors.fill: parent
61+
color: Color.mSurface
62+
opacity: 0.85
63+
radius: Style.radiusM
64+
65+
ColumnLayout {
66+
anchors.fill: parent
67+
anchors.margins: Style.marginL
68+
69+
// Render only when API is ready to ensure translations work correctly
70+
visible: root.pluginApi !== null
71+
72+
RowLayout {
73+
Layout.fillWidth: true
74+
75+
NText {
76+
text: root.pluginApi.tr("widget.heading")
77+
color: Color.mOnSurfaceVariant
78+
font.pointSize: Style.fontSizeL * widgetScale
79+
Layout.fillWidth: true
80+
}
81+
82+
NIconButton {
83+
// Strict translation: no fallback string used here
84+
icon: root.pluginApi.tr("widget.button")
85+
86+
Layout.preferredWidth: 32 * widgetScale
87+
Layout.preferredHeight: 32 * widgetScale
88+
89+
onClicked: {
90+
openIkhal.running = false
91+
openIkhal.running = true
92+
}
93+
}
94+
}
95+
96+
NScrollView {
97+
Layout.fillWidth: true
98+
Layout.fillHeight: true
99+
clip: true
100+
101+
// Force horizontal scrollbar off
102+
ScrollBar.horizontal.policy: ScrollBar.AlwaysOff
103+
104+
NText {
105+
// Force the text width to match the ScrollView's width
106+
width: parent.width
107+
text: root.calendarVal !== "" ? root.calendarVal : root.pluginApi.tr("widget.loading")
108+
109+
color: Color.mOnSurface
110+
font.pointSize: Style.fontSizeL * widgetScale
111+
wrapMode: Text.NoWrap
112+
elide: Text.ElideRight
113+
font.family: "Monospace"
114+
}
115+
}
116+
}
117+
}
118+
}

khal-agenda-widget/README.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Khal Agenda Widget
2+
![Preview](preview.png)
3+
4+
A theme aware Noctalia desktop plugin that displays agenda information.
5+
6+
## Features
7+
Shows the next 7 days of events.
8+
Icon click to open the full calendar.
9+
10+
## Configuration
11+
None
12+
13+
## Requirements
14+
- **Noctalia Shell**: 3.6.0 or later.
15+
- **System Dependencies**: khal, kitty
16+
17+
## Technical Details
18+
- **Data Source**: Uses khal command line and kitty terminal.
19+
- **Backend**: QML integration with shell-based data collection.

khal-agenda-widget/i18n/en.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"widget": {
3+
"loading": "Loading...",
4+
"no_events": "No upcoming events",
5+
"heading": "Agenda for 7 days.",
6+
"button": "calendar-month"
7+
}
8+
}

khal-agenda-widget/manifest.json

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"id": "khal-agenda-widget",
3+
"name": "Khal Agenda Info",
4+
"version": "1.0.0",
5+
"minNoctaliaVersion": "4.6.6",
6+
"author": "Simon",
7+
"license": "MIT",
8+
"repository": "https://github.com/noctalia-dev/noctalia-plugins",
9+
"description": "Shows khal agenda.",
10+
"tags": ["Desktop", "System"],
11+
"entryPoints": {
12+
"desktopWidget": "DesktopWidget.qml"
13+
},
14+
"metadata": {
15+
"defaultSettings": {}
16+
}
17+
}

khal-agenda-widget/preview.png

20.8 KB
Loading

0 commit comments

Comments
 (0)