Skip to content

Commit

Permalink
Widget update
Browse files Browse the repository at this point in the history
  • Loading branch information
DarkXero-dev committed Dec 5, 2024
1 parent 1d270c4 commit 55f5660
Show file tree
Hide file tree
Showing 26 changed files with 642 additions and 154 deletions.
21 changes: 11 additions & 10 deletions Configs/Home/.config/apdatifier/config.conf
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,26 @@ interval="true"
time="30"
checkOnStartup="true"
arch="true"
aur="false"
flatpak="false"
aur="true"
flatpak="true"
widgets="true"
newsArch="false"
newsArch="true"
newsKDE="true"
newsTWIK="false"
newsTWIK="true"
newsTWIKA="false"
newsKeep="3"
middleAction="upgradeSystem"
rightAction=""
scrollUpAction="switchInterval"
scrollDownAction="management"
notifyUpdates="true"
notifyEveryBump="true"
notifyAction="true"
notifyEveryBump="false"
notifyNews="true"
notifyErrors="false"
notifySound="true"
notifyPersistent="false"
wrapper="paru"
wrapper=""
upgradeFlags="true"
upgradeFlagsText=""
sudoBin="sudo"
Expand Down Expand Up @@ -49,13 +50,13 @@ counterSpacing="0"
counterMargins="0"
counterOffsetX="0"
counterOffsetY="0"
counterCenter="false"
counterCenter="true"
counterTop="true"
counterBottom="false"
counterRight="true"
counterLeft="false"
ownIconsUI="true"
listView="0"
listView="1"
spacing="6"
sorting="true"
showStatusText="true"
Expand All @@ -68,9 +69,9 @@ upgradeButton="true"
checkButton="true"
tabBarVisible="true"
tabBarTexts="true"
tabBarNewsRelevant="false"
tabBarNewsRelevant="true"
version="v2.9.0"
timestamp="1732214364317"
timestamp="1733431995059"
configMsg="false"
rulesMsg="false"

Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
<entry name="scrollUpAction" type="string"><default>switchInterval</default></entry>
<entry name="scrollDownAction" type="string"><default>management</default></entry>
<entry name="notifyUpdates" type="bool"><default>true</default></entry>
<entry name="notifyAction" type="bool"><default>false</default></entry>
<entry name="notifyEveryBump" type="bool"><default>true</default></entry>
<entry name="notifyNews" type="bool"><default>true</default></entry>
<entry name="notifyErrors" type="bool"><default>true</default></entry>
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ source "$(dirname "$0")/utils"

trap 'echo -e "\n\n$(colorize red bold $ICO_WARN "CTRL+C. $UPGRADE_SKIPPED")"' SIGINT

bin="$sudoBin pacman"; [ "$aur" = true ] && bin=$wrapper

fullSystemUpgrade() {
startTime=$(date +%s)

Expand All @@ -16,7 +18,6 @@ fullSystemUpgrade() {

[ "$mirrors" = true ] && { $scriptDir/mirrorlist; echo; }

local bin="$sudoBin pacman"; [ "$aur" = true ] && bin=$wrapper
local archCmd="$bin -Syu"; [ "$upgradeFlags" = true ] && archCmd="$archCmd $upgradeFlagsText"

printExec "$archCmd"
Expand Down Expand Up @@ -59,9 +60,9 @@ arch_package() {
printImportant "$UPGRADE_PARTIAL"
echo

printExec -Sy $1
printExec "$bin -Sy" $1

yay -Sy $1
$bin -Sy $1

printClose
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,6 @@ upgradeAllWidgets() {

makeList & printWhile $! "$WIDGETS_CHECK"

updated="false"
if [[ -s "$updatesList" ]] && jq -e '(. | length) > 0' "$updatesList" > /dev/null 2>&1; then
echo
jq -c 'sort_by(.NM)[]' "$updatesList" | while read -r widget; do
Expand All @@ -237,7 +236,8 @@ upgradeAllWidgets() {
done
fi

jq -c 'sort_by(.NM)[]' "$updatesList" | while read -r widget; do
updated=false
while read -r widget; do
name=$(echo "$widget" | jq -r '.NM')
contentId=$(echo "$widget" | jq -r '.CN')
latestVer=$(echo "$widget" | jq -r '.VN')
Expand All @@ -251,13 +251,12 @@ upgradeAllWidgets() {
[[ $exitCode -ne 0 ]] && { echo; continue; }

kpackagetool6 -t Plasma/Applet -u $(dirname $(find $tempDir/$name -name "metadata.json")) 2>/dev/null
updated=true
sleep 1
echo
done < <(jq -c 'sort_by(.NM)[]' "$updatesList")

updated="true"
done

[[ updated = true ]] && restartPlasmashell
[[ $updated = true ]] && restartPlasmashell
else
printDone "$MNG_DONE"
fi
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ function log(message) {

function Error(code, err) {
if (err) {
cfg.notifyErrors && sendNotify("error", i18n("Exit code: ") + code, err.trim())
cfg.notifyErrors && notify.send("error", i18n("Exit code: ") + code, err.trim())
sts.errMsg = err.trim().substring(0, 150) + "..."
setStatusBar(code)
return true
Expand Down Expand Up @@ -326,7 +326,7 @@ function updateNews(out) {
const currentNews = Array.from(Array(newsModel.count), (_, i) => newsModel.get(i))
news.forEach(item => {
if (!currentNews.some(currentItem => currentItem.link === item.link)) {
sendNotify("news", item.title, item.article)
notify.send("news", item.title, item.article)
}
})
}
Expand Down Expand Up @@ -479,7 +479,7 @@ function finalize(list) {
if (newList.length > 0) {
const title = i18np("+%1 new update", "+%1 new updates", newList.length)
const body = newList.map(pkg => `${pkg.NM}${pkg.VN}`).join("\n")
sendNotify("updates", title, body)
notify.send("updates", title, body)
}
}

Expand Down Expand Up @@ -515,23 +515,6 @@ function setStatusBar(code) {
}


let notifyParams = { "event": "", "title": "", "body": "", "icon": "", "urgency": "" }
function sendNotify(event, title, body) {
const eventParams = {
updates: { icon: "apdatifier-packages", urgency: "DefaultUrgency" },
news: { icon: "news-subscribe", urgency: "HighUrgency" },
error: { icon: "error", urgency: "HighUrgency" }
}

let { icon, urgency } = eventParams[event]

if (cfg.notifySound) event += "Sound"

notify = { event, title, body, icon, urgency }
notification.sendEvent()
}


function getLastCheckTime() {
if (!cfg.timestamp) return ""

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*
SPDX-FileCopyrightText: 2024 Evgeny Kazantsev <[email protected]>
SPDX-License-Identifier: MIT
*/

import QtQuick
import org.kde.notification
import "../../tools/tools.js" as JS

Item {
Component {
id: notifyComponent
Notification {
componentName: "apdatifier"
flags: cfg.notifyPersistent ? Notification.Persistent : Notification.CloseOnTimeout
}
}

Component {
id: actionComponent
NotificationAction {
label: i18n("Upgrade system")
onActivated: JS.upgradeSystem()
}
}

function send(event, title, body) {
const params = {
news: { icon: "news-subscribe", urgency: "HighUrgency" },
error: { icon: "error", urgency: "HighUrgency" },
updates: { icon: "apdatifier-packages", urgency: "DefaultUrgency" }
}

const { icon, urgency } = params[event]

const action = (event === "updates" && cfg.notifyAction) ? actionComponent.createObject(root) : []

if (cfg.notifySound) event += "Sound"

notifyComponent.createObject(root, {
eventId: event,
iconName: icon,
title: title,
text: body,
actions: action
})?.sendEvent()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ SimpleKCM {
property string cfg_scrollDownAction: plasmoid.configuration.scrollDownAction

property alias cfg_notifyUpdates: notifyUpdates.checked
property alias cfg_notifyAction: notifyAction.checked
property alias cfg_notifyEveryBump: notifyEveryBump.checked
property alias cfg_notifyNews: notifyNews.checked
property alias cfg_notifyErrors: notifyErrors.checked
Expand All @@ -55,7 +56,7 @@ SimpleKCM {
Component.onCompleted: {
JS.checkDependencies()
if (arch.checked && !pkg.pacman) arch.checked = plasmoid.configuration.arch = false
if (aur.checked && !pkg.pacman && !pkg.yay && !pkg.paru) aur.checked = plasmoid.configuration.aur = false
if (aur.checked && (!pkg.pacman || (!pkg.yay && !pkg.paru))) aur.checked = plasmoid.configuration.aur = false
if (flatpak.checked && !pkg.flatpak) flatpak.checked = plasmoid.configuration.flatpak = false
if (widgets.checked && !widgetsAvail) widgets.checked = plasmoid.configuration.widgets = false
if (newsArch.checked && !newsAvail) newsArch.checked = plasmoid.configuration.newsArch = false
Expand Down Expand Up @@ -290,10 +291,18 @@ SimpleKCM {
Kirigami.FormData.isSection: true
}

CheckBox {
Kirigami.FormData.label: i18n("Notifications") + ":"
id: notifyUpdates
text: i18n("For new updates")
RowLayout {
spacing: Kirigami.Units.largeSpacing * 2
CheckBox {
Kirigami.FormData.label: i18n("Notifications") + ":"
id: notifyUpdates
text: i18n("For new updates")
}
CheckBox {
id: notifyAction
text: i18n("Upgrade button")
enabled: notifyUpdates.checked
}
}

RowLayout {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
import QtQuick
import QtQuick.Layouts

import org.kde.notification
import org.kde.plasma.plasmoid
import org.kde.kirigami as Kirigami
import org.kde.plasma.core as PlasmaCore

import "components"
import "representation" as Rep
import "../tools/tools.js" as JS

Expand All @@ -37,7 +37,6 @@ PlasmoidItem {

property var check
property var cache: []
property var notify: JS.notifyParams
property int time: plasmoid.configuration.time
property bool interval: plasmoid.configuration.interval
property bool sorting: plasmoid.configuration.sorting
Expand Down Expand Up @@ -75,14 +74,7 @@ PlasmoidItem {
}

Notification {
id: notification
componentName: "apdatifier"
eventId: notify.event
title: notify.title
text: notify.body
iconName: notify.icon
flags: cfg.notifyPersistent ? Notification.Persistent : Notification.CloseOnTimeout
urgency: Notification[notify.urgency] || Notification.DefaultUrgency
id: notify
}

Plasmoid.contextualActions: [
Expand Down
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
{
"KPlugin": {
"Authors": [
{
"Name": "Evgeny Kazantsev",
"Email": "[email protected]"
}
],
"Category": "System Information",
"Description": "Arch Update Notifier",
"Icon": "apdatifier-plasmoid",
"Id": "com.github.exequtic.apdatifier",
"Name": "Apdatifier",
"EnabledByDefault": true,
"Version": "2.9.0",
"License": "MIT",
"BugReportUrl": "https://github.com/exequtic/apdatifier/issues",
"Website": "https://github.com/exequtic/apdatifier"
},
"KPackageStructure": "Plasma/Applet",
"X-Plasma-API-Minimum-Version": "6.0",
"X-Plasma-NotificationArea": "true",
"X-Plasma-NotificationAreaCategory": "SystemServices"
"KPlugin": {
"Authors": [
{
"Name": "Evgeny Kazantsev",
"Email": "[email protected]"
}
],
"Category": "System Information",
"Description": "Arch Update Notifier",
"Icon": "apdatifier-plasmoid",
"Id": "com.github.exequtic.apdatifier",
"Name": "Apdatifier",
"EnabledByDefault": true,
"Version": "2.9.0",
"License": "MIT",
"BugReportUrl": "https://github.com/exequtic/apdatifier/issues",
"Website": "https://github.com/exequtic/apdatifier"
},
"KPackageStructure": "Plasma/Applet",
"X-Plasma-API-Minimum-Version": "6.0",
"X-Plasma-NotificationArea": "true",
"X-Plasma-NotificationAreaCategory": "SystemServices"
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Copy the [`template.pot`](template.pot) file to [`./po`](po) directory and name
|----------|---------|-------|
| Template | 232 | |
| de | 184/232 | 79% |
| es | 184/232 | 79% |
| es | 232/232 | 100% |
| fr | 184/232 | 79% |
| ko | 136/232 | 58% |
| nl | 185/232 | 79% |
Expand Down
Loading

0 comments on commit 55f5660

Please sign in to comment.