Index: plasma-workspace/CMakeLists.txt =================================================================== --- plasma-workspace/CMakeLists.txt +++ plasma-workspace/CMakeLists.txt @@ -142,6 +142,7 @@ add_subdirectory(plasma-windowed) add_subdirectory(shell) add_subdirectory(freespacenotifier) +add_subdirectory(freememorynotifier) add_subdirectory(klipper) add_subdirectory(krunner) add_subdirectory(ksmserver) Index: plasma-workspace/freememorynotifier/CMakeLists.txt =================================================================== --- /dev/null +++ plasma-workspace/freememorynotifier/CMakeLists.txt @@ -0,0 +1,40 @@ +add_definitions(-DTRANSLATION_DOMAIN=\"freememorynotifier\") + +set(kcm_freememorynotifier_SRCS kcm_freememorynotifier.cpp) +set(kded_freememorynotifier_SRCS freememorynotifier.cpp module.cpp) + +ki18n_wrap_ui(kcm_freememorynotifier_SRCS freememorynotifier_prefs_base.ui) +kconfig_add_kcfg_files(kded_freememorynotifier_SRCS settings.kcfgc) + +add_library(kcm_freememorynotifier MODULE ${kcm_freememorynotifier_SRCS}) +add_library(freememorynotifier MODULE ${kded_freememorynotifier_SRCS}) +kcoreaddons_desktop_to_json(freememorynotifier freememorynotifier.desktop) +kcoreaddons_desktop_to_json(kcm_freememorynotifier kcm_freememorynotifier.desktop) + +target_link_libraries(kcm_freememorynotifier + KF5::KCMUtils + KF5::I18n + Qt5::DBus +) + +target_link_libraries(freememorynotifier + KF5::ConfigWidgets + KF5::DBusAddons + KF5::I18n + KF5::KIOCore + KF5::KIOWidgets + KF5::Notifications + KF5::ProcessCore + Qt5::DBus +) + +install(TARGETS kcm_freememorynotifier DESTINATION ${PLUGIN_INSTALL_DIR} ) +install(TARGETS freememorynotifier DESTINATION ${KDE_INSTALL_PLUGINDIR}/kf5/kded ) + + +########### install files ############### + +install( FILES kcm_freememorynotifier.desktop DESTINATION ${SERVICES_INSTALL_DIR} ) +install( FILES freememorynotifier.desktop DESTINATION ${SERVICES_INSTALL_DIR} ) +install( FILES freememorynotifier.notifyrc DESTINATION ${KDE_INSTALL_KNOTIFY5RCDIR} ) +install( FILES freememorynotifier.kcfg DESTINATION ${KDE_INSTALL_KCFGDIR} ) Index: plasma-workspace/freememorynotifier/COPYING =================================================================== --- /dev/null +++ plasma-workspace/freememorynotifier/COPYING @@ -0,0 +1,346 @@ +NOTE! The GPL below is copyrighted by the Free Software Foundation, but +the instance of code that it refers to (the kde programs) are copyrighted +by the authors who actually wrote it. + +--------------------------------------------------------------------------- + + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc. + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Library General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) 19yy + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) 19yy name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + , 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Library General +Public License instead of this License. Index: plasma-workspace/freememorynotifier/Messages.sh =================================================================== --- /dev/null +++ plasma-workspace/freememorynotifier/Messages.sh @@ -0,0 +1,3 @@ +#! /bin/sh +$EXTRACTRC *.ui *.kcfg >> rc.cpp +$XGETTEXT *.cpp -o $podir/freememorynotifier.pot Index: plasma-workspace/freememorynotifier/README =================================================================== --- /dev/null +++ plasma-workspace/freememorynotifier/README @@ -0,0 +1,3 @@ +This is a small KDED module that monitors free RAM +and shows a warning dialog when it runs too low, +with a configurable limit and the possibility to postpone. Index: plasma-workspace/freememorynotifier/freememorynotifier.h =================================================================== --- /dev/null +++ plasma-workspace/freememorynotifier/freememorynotifier.h @@ -0,0 +1,67 @@ +/* This file is part of the KDE Project + Copyright (c) 2006 Lukas Tinkl + Copyright (c) 2008 Lubos Lunak + Copyright (c) 2009 Ivo Anjo + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#ifndef _FREEMEMORYNOTIFIER_H_ +#define _FREEMEMORYNOTIFIER_H_ + +#include +#include + +#include +#include + +class KNotification; +class KStatusNotifierItem; + +class FreeMemoryNotifier : public QObject +{ + Q_OBJECT + +public: + FreeMemoryNotifier(QObject *parent = NULL); + ~FreeMemoryNotifier() override; + +public Q_SLOTS: + Q_SCRIPTABLE Q_NOREPLY void reload(); + +private Q_SLOTS: + void updateMenu(); + void checkFreeMemory(); + void resetLastAvailable(); + void cleanupNotification(); + void configDialogClosed(); + void showTaskManager(); + void killProcess(); + +private: + QTimer timer; + QTimer *m_lastAvailTimer; + KNotification *m_notification; + qint64 m_lastAvail; // used to suppress repeated warnings when available space hasn't changed + const KSysGuard::Process *m_process; + KSysGuard::Processes *m_processes; + + int m_threshold; + bool m_enableNotification; + + void disableFMNotifier(); + bool dbusError(QDBusInterface &iface); +}; + +#endif Index: plasma-workspace/freememorynotifier/freememorynotifier.cpp =================================================================== --- /dev/null +++ plasma-workspace/freememorynotifier/freememorynotifier.cpp @@ -0,0 +1,306 @@ +/* This file is part of the KDE Project + Copyright (c) 2018 Oleg Solovyov + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#include "freememorynotifier.h" +#include + +/* for getuid() */ +#include + +#include +#include +#include + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "settings.h" + +#include +#include +#include + +FreeMemoryNotifier::FreeMemoryNotifier(QObject *parent) + : QObject(parent) + , m_lastAvailTimer(NULL) + , m_notification(NULL) + , m_lastAvail(-1) + , m_processes(new KSysGuard::Processes()) +{ + reload(); + + connect(&timer, &QTimer::timeout, this, &FreeMemoryNotifier::checkFreeMemory); + timer.start(1000 * 5 /* 5 seconds */); +} + +FreeMemoryNotifier::~FreeMemoryNotifier() +{ + // The notification is automatically destroyed when it goes away, so we only need to do this if + // it is still being shown + if (m_notification) { + m_notification->close(); + } +} + +void FreeMemoryNotifier::reload() +{ + KSharedConfig::Ptr cfg = KSharedConfig::openConfig(QStringLiteral("memorynotifierrc")); + KConfigGroup grp = cfg->group("General"); + + // If we are running, notifications are enabled + m_enableNotification = grp.readEntry("enableNotification", true); + + m_threshold = grp.readEntry("threshold", 10); + + qDebug() << "Settings:" << m_enableNotification << m_threshold; +} + +void FreeMemoryNotifier::updateMenu() +{ + m_processes->updateAllProcesses(); + const QList processlist = m_processes->getAllProcesses(); + + qlonglong max_usage = 0; + foreach (const KSysGuard::Process *process, processlist) { + if (process->uid() != getuid()) + continue; + qlonglong size = process->vmRSS(); + qDebug() << "Trying" << process->name() << max_usage << size; + if (size > max_usage) { + max_usage = size; + m_process = process; + qDebug() << "max_usage" << process->name(); + } + } + qDebug() << "Most greedy process is" << m_process->name(); +} + +void FreeMemoryNotifier::checkFreeMemory() +{ + if (!m_enableNotification) { + // do nothing if notifying is disabled; + // also stop the timer that probably got us here in the first place + timer.stop(); + + return; + } + + updateMenu(); + + quint64 freeram, buffers, totalram, cached = 0; + quint64 freeswap = 0, totalswap = 0; + quint64 total, free; + + struct sysinfo info; + + sysinfo(&info); /* Get Information from system... */ + + /* + * The sysinfo.mem_unit member variable is not available in older 2.4 kernels. + * If you have troubles compiling this code, set mem_unit to "1". + */ + + const int mem_unit = info.mem_unit; + + totalram = (quint64)(info.totalram) * mem_unit; // total physical memory (without swaps) + freeram = (quint64)(info.freeram) * mem_unit; // total free physical memory (without swaps) + buffers = (quint64)(info.bufferram) * mem_unit; // total disk buffer memory (without swaps) + + QFile file(QStringLiteral("/proc/meminfo")); + if (file.open(QIODevice::ReadOnly)) { + char buf[512]; + while (file.readLine(buf, sizeof(buf) - 1) > 0) { + if (strncmp(buf,"Cached:",7)==0) { + unsigned long v; + v = strtoul(&buf[7],NULL,10); + cached = (quint64)(v) * 1024; // Cached memory in RAM + break; + } + } + + file.close(); + } + + // convert everything to MiB + cached /= 1024 * 1024; + buffers /= 1024 * 1024; + + totalswap = (quint64)(info.totalswap) * mem_unit; // total physical memory (swap only) + freeswap = (quint64)(info.freeswap) * mem_unit; // total free physical memory (swap only) + + if (totalswap > 0) { // there is some swap + total = (totalram + totalswap) / (1024 * 1024); // to MiB + free = (freeram + freeswap) / (1024 * 1024); // to MiB + } else { // no swap + total = totalram / (1024 * 1024); // to MiB + free = freeram / (1024 * 1024); // to MiB + } + + qint64 limit = (total * m_threshold) / 100; + qint64 avail = free + cached + buffers; + bool warn = false; + + qDebug() << QStringLiteral("Free Memory Notifier: limit: %1 MiB").arg(limit); + qDebug() << "Free Memory Notifier: " << freeram << freeswap << cached << buffers << "MiB"; + qDebug() << QStringLiteral("Free Memory Notifier: available: %1 MiB").arg(avail); + + if (avail < limit) { + int availpct = int(100 * avail / total); + qDebug() << QStringLiteral("Free Memory Notifier: available: %1 MiB (%2 %)").arg(avail).arg(availpct); + // avail memory dropped under a limit + if (m_lastAvail < 0 || avail < m_lastAvail / 2) { // always warn the first time or when available dropped to a half of previous one, warn again + m_lastAvail = avail; + warn = true; + } else if (avail > m_lastAvail) { // the user freed some space + m_lastAvail = avail; // so warn if it goes low again + } + // do not change lastAvail otherwise, to handle free memory slowly going down + + if (warn) { + m_notification = new KNotification(QStringLiteral("freememorynotif")); + m_notification->setText(i18nc("Warns the user that the system is running low on space on his RAM, indicating the percentage and absolute MiB size remaining", + "Your memory is running out of available space, you have %1 MiB remaining (%2%)", QLocale::system().toString(avail), availpct)); + + connect(m_notification, &KNotification::closed, this, &FreeMemoryNotifier::cleanupNotification); + + m_notification->setComponentName(QStringLiteral("freememorynotifier")); + m_notification->sendEvent(); + + QStringList actions; + actions.append(i18n("Kill %1", m_process->name())); + actions.append(i18n("Open task manager")); + + m_notification->setActions(actions); + connect(m_notification, &KNotification::action1Activated, this, &FreeMemoryNotifier::killProcess); + connect(m_notification, &KNotification::action2Activated, this, &FreeMemoryNotifier::showTaskManager); + } + } else { // the user freed some memory below warn limit + m_lastAvail = -1; // warn again if it goes under limit again + } +} + +void FreeMemoryNotifier::killProcess() +{ + QString msg; + QString title; + QString dontAskAgainKey; + QString closeButton; + msg = i18n("Are you sure you want to end this process? Any unsaved work may be lost."); + title = i18nc("Dialog title", "End Process"); + dontAskAgainKey = QStringLiteral("endconfirmation"); + closeButton = i18n("End"); + + int res = KMessageBox::warningContinueCancelList(new QWidget(), msg, QStringList(m_process->name()), + title, + KGuiItem(closeButton, QStringLiteral("process-stop")), + KStandardGuiItem::cancel(), + dontAskAgainKey); + if (res != KMessageBox::Continue) + return; + + m_processes->sendSignal(m_process->pid(), SIGTERM); +} + +void FreeMemoryNotifier::showTaskManager() +{ + QDBusConnection con = QDBusConnection::sessionBus(); + QDBusConnectionInterface* interface = con.interface(); + if (interface->isServiceRegistered(QStringLiteral("org.kde.systemmonitor"))) { + QDBusMessage msg = QDBusMessage::createMethodCall(QStringLiteral("org.kde.systemmonitor"), + QStringLiteral("/"), + QStringLiteral("org.qtproject.Qt.QWidget"), + QStringLiteral("showMaximized")); + + con.asyncCall(msg); + } + else { + QString exe = QStandardPaths::findExecutable(QStringLiteral("systemmonitor")); + QProcess::startDetached(exe, QStringList("--ignore-config")); + } +} + +void FreeMemoryNotifier::cleanupNotification() +{ + if (m_notification) { + m_notification->close(); + } + m_notification = NULL; + + // warn again if constantly below limit for too long + if (m_lastAvailTimer == NULL) { + m_lastAvailTimer = new QTimer(this); + connect(m_lastAvailTimer, &QTimer::timeout, this, &FreeMemoryNotifier::resetLastAvailable); + } + m_lastAvailTimer->start(1000 * 60 * 60 /* 1 hour*/); +} + +void FreeMemoryNotifier::resetLastAvailable() +{ + m_lastAvail = -1; + m_lastAvailTimer->deleteLater(); + m_lastAvailTimer = NULL; +} + +void FreeMemoryNotifier::configDialogClosed() +{ + if (!m_enableNotification) { + disableFMNotifier(); + } +} + +/* The idea here is to disable ourselves by telling kded to stop autostarting us, and + * to kill the current running instance. + */ +void FreeMemoryNotifier::disableFMNotifier() +{ + QDBusInterface iface(QStringLiteral("org.kde.kded5"), + QStringLiteral("/kded"), + QStringLiteral("org.kde.kded5") ); + if (dbusError(iface)) { + return; + } + + // Disable current module autoload + iface.call(QStringLiteral("setModuleAutoloading"), QStringLiteral("FreeMemoryNotifier"), false); + if (dbusError(iface)) { + return; + } + + // Unload current module + iface.call(QStringLiteral("unloadModule"), QStringLiteral("FreeMemoryNotifier")); + if (dbusError(iface)) { + return; + } +} + +bool FreeMemoryNotifier::dbusError(QDBusInterface &iface) +{ + QDBusError err = iface.lastError(); + if (err.isValid()) { + qCritical() << "Failed to perform operation on kded [" << err.name() << "]:" << err.message(); + return true; + } + return false; +} Index: plasma-workspace/freememorynotifier/freememorynotifier.desktop =================================================================== --- /dev/null +++ plasma-workspace/freememorynotifier/freememorynotifier.desktop @@ -0,0 +1,130 @@ +[Desktop Entry] +Type=Service +X-KDE-ServiceTypes=KDEDModule +X-KDE-Library=freememorynotifier +X-KDE-DBus-ModuleName=freememorynotifier +X-KDE-Kded-autoload=true + +Name=Free Memory Notifier +Name[ar]=مُخطِر المساحة الحرّة +Name[bg]=Уведомяване за свободно пространство +Name[bs]=Izvještač o slobodnom prostoru +Name[ca]=Notificador d'espai lliure +Name[ca@valencia]=Notificador d'espai lliure +Name[cs]=Oznamování volného místa +Name[da]=Bekendtgørelse om ledig plads +Name[de]=Speicherplatzbenachrichtigung +Name[el]=Ειδοποίηση ελεύθερου χώρου +Name[en_GB]=Free Space Notifier +Name[es]=Notificador de espacio libre +Name[et]=Vaba ruumi teavitaja +Name[eu]=Leku askearen jakinarazlea +Name[fi]=Vapaan tilan ilmoitin +Name[fr]=Notification d'espace libre +Name[ga]=Fógróir Spáis Shaoir +Name[gl]=Notificador de espazo libre +Name[he]=Free Space Notifier +Name[hi]=खाली स्थान सूचक +Name[hr]=Glasnik slobodnog prostora +Name[hu]=Szabad hely értesítő +Name[ia]=Notificator de spatio libere +Name[id]=Notifikasi Ruang Kosong +Name[is]=Tilkynningar um laust pláss +Name[it]=Notificatore dello spazio libero +Name[ja]=空き領域の通知 +Name[kk]=KDE-нің бос орын туралы құлақтандыруы +Name[km]=កម្មវិធី​ជូនដំណឹង​​ទំហំ​ទំនេរ +Name[kn]=ಖಾಲಿ ಜಾಗ ಸೂಚಕ +Name[ko]=남은 공간 알림이 +Name[lt]=Laisvos vietos pranešėjas +Name[lv]=Brīvās vietas ziņotājs +Name[ml]=ലഭ്യമായ സ്ഥലം അറിയിക്കുന്നതിനുള്ള സംവിധാനം +Name[mr]=मोकळी जागा निदर्शक +Name[nb]=Ledig plass-varsler +Name[nds]=Freeruumbescheden +Name[nl]=Vrije ruimte-melder +Name[nn]=Varsel om lite ledig plass +Name[pa]=ਖਾਲੀ ਥਾਂ ਨੋਟੀਫਾਇਰ +Name[pl]=Powiadomienie o wolnym miejscu +Name[pt]=Notificação de Espaço Livre +Name[pt_BR]=Notificação de espaço livre +Name[ro]=Notificare spațiu liber +Name[ru]=Слежение за памятью +Name[si]=හිස් ඉඩ දැනුම් දෙන්නා +Name[sk]=Monitor voľného miesta +Name[sl]=Obvestilnik o neporabljenem prostoru +Name[sr]=Извештавач о слободном простору +Name[sr@ijekavian]=Извјештавач о слободном простору +Name[sr@ijekavianlatin]=Izvještavač o slobodnom prostoru +Name[sr@latin]=Izveštavač o slobodnom prostoru +Name[sv]=Information om ledigt utrymme +Name[th]=ตัวแจ้งพื้นที่ว่าง +Name[tr]=Boş Alan Bildirici +Name[ug]=بىكار بوشلۇق خەۋەرچىسى +Name[uk]=Сповіщення про вільне місце +Name[vi]=Trình thông báo không gian trống +Name[wa]=Notifieu del plaece di libe +Name[x-test]=xxFree Space Notifierxx +Name[zh_CN]=空闲空间通知器 +Name[zh_TW]=剩餘空間通知 +Comment=Warns when running out of memory +Comment[ar]=يحذّرك عندما تنفذ مساحة مجلد المنزل +Comment[bg]=Предупреждение при твърде малко пространство в домашната директория +Comment[bn]=ব্যক্তিগত ফোল্ডারে জায়গা কমে গেলে সতর্ক করে +Comment[bs]=Upozorava kada vam ponestaje prostora u ličnom direktoriju +Comment[ca]=Avisa quan s'exhaureix l'espai de la carpeta personal +Comment[ca@valencia]=Avisa quan s'exhaureix l'espai de la carpeta personal +Comment[cs]=Varování při blížícím se nedostatku místa v domácí složce +Comment[da]=Advarer når du er ved at løbe tør for plads i din hjemmemappe +Comment[de]=Gibt eine Warnung aus, wenn der freie Speicherplatz in Ihrem Persönlichen Ordner knapp wird +Comment[el]=Προειδοποιεί όταν τελειώνει ο ελεύθερος χώρος στον 'Προσωπικό φάκελό' σας +Comment[en_GB]=Warns when running out of space on your home folder +Comment[es]=Le avisa cuando se está quedando sin espacio en su carpeta personal +Comment[et]=Hoiatus, kui kodukataloogis hakkab ruumi nappima +Comment[eu]=Abisua ematen du etxeko karpetan lekurik gabe gelditzen ari zarenean +Comment[fi]=Varoittaa kun kotikansiosta on tila loppumassa +Comment[fr]=Avertit lorsque l'espace vient à manquer dans votre dossier utilisateur +Comment[ga]=Tugann sé rabhadh duit nuair atá d'fhillteán baile ag éirí lán +Comment[gl]=Avisa cando se está a quedar sen espazo no cartafol persoal +Comment[he]=משמש לאזהרה כאשר המקום הפנוי בתיקיית הבית מועט +Comment[hr]=Upozori kada nestaje prostora u mojoj korisničkoj mapi +Comment[hu]=Figyelmeztet, ha kezd elfogyni a szabad lemezterület a saját könyvtárában +Comment[ia]=Il avisa quando il termina le spatio sur tu dossier domo +Comment[id]=Memperingatkan jika kehabisan ruang kosong di folder rumah anda +Comment[is]=Varar við þegar lítið pláss er eftir í heimamöppunni þinni +Comment[it]=Avvisa quando si sta esaurendo lo spazio nella tua cartella Home +Comment[ja]=ホームフォルダの空き領域が少なくなったとき警告します +Comment[kk]=Мекен қапшығыңызда орын тапшылығы туралы ескерту +Comment[km]=ព្រមាន នៅពេល​ដំណើរការ​អស់ទំហំ​នៅ​លើ​ក្នុង​​ផ្ទះ​របស់​អ្នក +Comment[kn]=ನೆಲೆ ಕೋಶದಲ್ಲಿ ಖಾಲಿ ಸ್ಥಳವು ಇದಕ್ಕಿಂತ ಕಡಿಮೆಯಾದರೆ ಎಚ್ಚರಿಸುತ್ತದೆ +Comment[ko]=홈 폴더에 공간이 없을 때 알려 줍니다 +Comment[lt]=Įspėja, kai namų aplanke baigiasi laisva vieta +Comment[lv]=Brīdina, kad mājas mapē beidzas brīvā vieta +Comment[mr]=तुमच्या मुख्य संचयीकेतील जागा संपत आल्याची सूचना देतो +Comment[nb]=Varsler når det er lite plass igjen i hjemmemappa +Comment[nds]=Wohrschoen bi to minn free Ruum binnen Dien Tohuusorner +Comment[nl]=Geeft een waarschuwing bij een lage stand van de vrije ruimte voor uw persoonlijke map +Comment[nn]=Varslar når det er lite plass i heimemappa +Comment[pa]=ਚੇਤਾਵਨੀ ਦਿਉ, ਜਦੋਂ ਤੁਹਾਡੇ ਘਰ ਫੋਲਡਰ ਉੱਤੇ ਥਾਂ ਖਤਮ ਹੋ ਰਹੀ ਹੋਵੇ +Comment[pl]=Ostrzega, kiedy zaczyna brakować miejsca w katalogu domowym +Comment[pt]=Avisa de estiver com falta de espaço na sua pasta pessoal +Comment[pt_BR]=Avisa quando ficar sem espaço na sua pasta pessoal +Comment[ro]=Atenționează când spațiul de stocare din dosarul acasă este pe cale să se termine +Comment[ru]=Предупреждает о нехватке памяти +Comment[si]=ඔබගේ නිවාස බහාලුමේ ඉඩ අඩුවෙන් ධාවනය වෙන විට ඇනතුරු අඟවයි +Comment[sk]=Upozorňuje, keď dochádza voľné miesto v domovskom priečinku +Comment[sl]=Opozori, ko v domači mapi primanjkuje prostora +Comment[sr]=Упозорава када вам понестаје простора у домаћој фасцикли +Comment[sr@ijekavian]=Упозорава када вам понестаје простора у домаћој фасцикли +Comment[sr@ijekavianlatin]=Upozorava kada vam ponestaje prostora u domaćoj fascikli +Comment[sr@latin]=Upozorava kada vam ponestaje prostora u domaćoj fascikli +Comment[sv]=Varnar när utrymmet i hemkatalogen håller på att ta slut +Comment[th]=เตือนเมื่อพื้นที่ในโฟลเดอร์บ้านเหลือน้อย +Comment[tr]=Ev dizininizde boş alan azaldığı zaman uyarır +Comment[ug]=ماكان قىسقۇچىڭىزدىكى دىسكا بوشلۇقى ئاز قالغاندا ئەسكەرتىدۇ +Comment[uk]=Попереджає, якщо у домашній теці залишається мало місця +Comment[vi]=Cảnh báo khi sắp hết không gian cho thư mục chính của bạn +Comment[wa]=Advierti cwand i gn a cåzu pupont d' plaece dins vosse ridant måjhon +Comment[x-test]=xxWarns when running out of space on your home folderxx +Comment[zh_CN]=在您主目录磁盘空间过低时发出警告 +Comment[zh_TW]=當您的家目錄剩餘空間快不足時警告您 Index: plasma-workspace/freememorynotifier/freememorynotifier.kcfg =================================================================== --- /dev/null +++ plasma-workspace/freememorynotifier/freememorynotifier.kcfg @@ -0,0 +1,23 @@ + + + + + + + 10 + 0 + 100 + + + + 1 + + + + 0 + + + Index: plasma-workspace/freememorynotifier/freememorynotifier.notifyrc =================================================================== --- /dev/null +++ plasma-workspace/freememorynotifier/freememorynotifier.notifyrc @@ -0,0 +1,417 @@ +[Global] +IconName=drive-harddisk +Comment=KDE Free Space Notifier Daemon +Comment[ar]=عفريت مُخطِر كدي للمساحة الحرة +Comment[bg]=Демон на KDE за свободно пространство +Comment[bn]=কে.ডি.ই. ফ্রী স্পেস বিজ্ঞপ্তি ডিমন +Comment[bs]=KDE‑ov demon izveštavača o slobodnom prostoru +Comment[ca]=Dimoni de notificacions d'espai lliure del KDE +Comment[ca@valencia]=Dimoni de notificacions d'espai lliure del KDE +Comment[cs]=Upozorňovací démon volného místa KDE +Comment[da]=KDE dæmon til bekendtgørelse om ledig plads +Comment[de]=KDE-Dienst für Speicherplatzbenachrichtigung +Comment[el]=Δαίμονας ειδοποιήσεων ελευθέρου χώρου του KDE +Comment[en_GB]=KDE Free Space Notifier Dæmon +Comment[es]=Demonio de notificaciones de espacio libre de KDE +Comment[et]=KDE vaba ruumi teavitamise deemon +Comment[eu]=KDEren leku askea jakinarazteko daimona +Comment[fi]=KDE:n vapaan tilan ilmoitustaustaprosessi +Comment[fr]=Démon de notification d'espace libre de KDE +Comment[ga]=Fógróir Spáis Shaoir KDE +Comment[gl]=Servizo de KDE de notificación do espazo libre +Comment[he]=KDE Free Space Notifier Daemon +Comment[hi]=केडीई खाली स्थान सूचना डेमन +Comment[hr]=KDE-ov servis za obavještavanje o slobodnom prostoru +Comment[hu]=KDE szabad hely értesítő szolgáltatás +Comment[ia]=Demone de notification de spatio libere de KDE +Comment[id]=Jurik Notifikasi RUang Kosong KDE +Comment[is]=KDE tilkynningaþjónn fyrir laust pláss +Comment[it]=Demone di notifica dello spazio libero di KDE +Comment[ja]=KDE 空き領域デーモン +Comment[kk]=KDE-нің бос орын туралы құлақтандыру қызметі +Comment[km]=ដេមិន​​ជូន​ដំណឹង​​ទំហំ​ទំនេរ​របស់ KDE +Comment[kn]=ಕೆಡಿಇ ಖಾಲಿ ಜಾಗ ಸೂಚನಾ ನೇಪಥಿಕ (ಡೀಮನ್) +Comment[ko]=KDE 남은 공간 알림 데몬 +Comment[lt]=KDE laisvos vietos pranešimų tarnyba +Comment[lv]=KDE brīvās vietas paziņošanas dēmons +Comment[ml]=കെഡിഇയിലെ ലഭ്യമായ സ്ഥലം അറിയിയ്ക്കുന്നതിനുള്ള നിരന്തര പ്രവൃത്തി +Comment[mr]=केडीई मोकळी जागा निदर्शक डीमन +Comment[nb]=KDEs varslingsdaemon for ledig plass +Comment[nds]=KDE-Dämoon för Freeruumbescheden +Comment[nl]=KDE-daemon voor het melden van vrije ruimte +Comment[nn]=KDE-varsel om lite plass +Comment[pa]=KDE ਖਾਲੀ ਥਾਂ ਨੋਟੀਫਿਕੇਸ਼ਨ ਡੈਮਨ +Comment[pl]=Usługa powiadamiania o wolnym miejscu KDE +Comment[pt]=Servidor de Notificação de Espaço Livre do KDE +Comment[pt_BR]=Serviço de notificação de espaço livre do KDE +Comment[ro]=Demon de notificare KDE a spațiului liber +Comment[ru]=Служба уведомлений о свободном месте на диске +Comment[si]=KDE හිස් ඉඩ දැනුම්දීමේ ඩීමනය +Comment[sk]=Monitor voľného miesta KDE +Comment[sl]=KDE-jev obvestilnik o neporabljenem prostoru +Comment[sr]=КДЕ‑ов демон извештавача о слободном простору +Comment[sr@ijekavian]=КДЕ‑ов демон извјештавача о слободном простору +Comment[sr@ijekavianlatin]=KDE‑ov demon izvještavača o slobodnom prostoru +Comment[sr@latin]=KDE‑ov demon izveštavača o slobodnom prostoru +Comment[sv]=KDE:s demon för information om ledigt utrymme +Comment[th]=ดีมอนการแจ้งพื้นที่ว่างของ KDE +Comment[tr]=KDE Boş Alan Bildirme Servisi +Comment[ug]=KDE بىكار بوشلۇق خەۋەرچى نازارەتچىسى +Comment[uk]=Фонова служба сповіщення про переповнення диска KDE +Comment[vi]=Trình nền thông báo không gian trống KDE +Comment[wa]=Démon KDE notifieu del plaece di libe +Comment[x-test]=xxKDE Free Space Notifier Daemonxx +Comment[zh_CN]=KDE 空闲空间通知守护程序 +Comment[zh_TW]=KDE 剩餘空間通知伺服程式 +Name=Low Disk Space +Name[ar]=مساحة القرص منخفضة +Name[bg]=Дисковото пространство е твърде малко +Name[bn]=ডিস্ক-এ জায়গা কম +Name[bs]=Malo prostora na disku +Name[ca]=Espai escàs al disc +Name[ca@valencia]=Espai escàs al disc +Name[cs]=Málo místa na disku +Name[da]=Lav diskplads +Name[de]=Wenig Speicherplatz +Name[el]=Χαμηλή χωρητικότητα δίσκου +Name[en_GB]=Low Disk Space +Name[es]=Poco espacio en disco +Name[et]=Kettaruumi napib +Name[eu]=Leku gutxi diskoan +Name[fi]=Vähäinen levytila +Name[fr]=Espace disque faible +Name[ga]=Easpa Spáis ar an Diosca +Name[gl]=Pouco espazo no disco +Name[he]=שטח מועט פנוי בדיסק +Name[hi]=डिस्क जगह कम +Name[hr]=Malo prostora na disku +Name[hu]=Kevés a lemezterület +Name[ia]=Spatio de disco basse +Name[id]=Ruang Kosong Tinggal Sedikit +Name[is]=Lítið diskpláss +Name[it]=Poco spazio su disco +Name[ja]=ディスクの空き領域が少ないです +Name[kk]=Дискіде орын тапшылығы +Name[km]=ទំហំ​ថាស​ទាប +Name[kn]=ಕಡಿಮೆ ಡಿಸ್ಕ್‌ ಜಾಗ +Name[ko]=디스크 공간 부족 +Name[lt]=Mažai vietos diske +Name[lv]=Maz diska vietas +Name[mai]=कम डिस्क स्थान +Name[ml]=ഡിസ്കില്‍ സഥലം കുറവാണു് +Name[mr]=डिस्कवर कमी जागा शिल्लक आहे +Name[nb]=Lite diskplass +Name[nds]=To minn free Ruum op de Fastplaat +Name[nl]=Schijf bijna vol +Name[nn]=Lite diskplass +Name[pa]=ਘੱਟ ਡਿਸਕ ਥਾਂ +Name[pl]=Mało miejsca na dysku +Name[pt]=Pouco Espaço em Disco +Name[pt_BR]=Pouco espaço em disco +Name[ro]=Spațiu pe disc scăzut +Name[ru]=Недостаточно места на диске +Name[si]=පහත් තැටි ඉඩ +Name[sk]=Nedostatok miesta na disku +Name[sl]=Prostora na disku je malo +Name[sr]=Мало простора на диску +Name[sr@ijekavian]=Мало простора на диску +Name[sr@ijekavianlatin]=Malo prostora na disku +Name[sr@latin]=Malo prostora na disku +Name[sv]=Ont om diskutrymme +Name[th]=พื้นที่ดิสก์เหลือน้อย +Name[tr]=Düşük Disk Alanı +Name[ug]=دىسكىدىكى بوشلۇق ئاز +Name[uk]=Замало місця на диску +Name[vi]=Dung lượng đĩa trống thấp +Name[wa]=Pus bråmint d' plaece sol plake +Name[x-test]=xxLow Disk Spacexx +Name[zh_CN]=磁盘空间低 +Name[zh_TW]=磁碟空間過低 + +[Context/warningnot] +Name=Warning +Name[af]=Waarskuwing +Name[ar]=تحذير +Name[as]=সতৰ্কবাণী +Name[be]=Папярэджанне +Name[be@latin]=Uvaha +Name[bg]=Предупреждение +Name[bn]=সতর্কবার্তা +Name[bn_IN]=সতর্কবার্তা +Name[bs]=Upozorenje +Name[ca]=Avís +Name[ca@valencia]=Avís +Name[cs]=Varování +Name[csb]=Bôczënk +Name[da]=Advarsel +Name[de]=Warnung +Name[el]=Προειδοποίηση +Name[en_GB]=Warning +Name[eo]=Averto +Name[es]=Aviso +Name[et]=Hoiatus +Name[eu]=Abisua +Name[fi]=Varoitus +Name[fr]=Avertissement +Name[fy]=Warskôging +Name[ga]=Rabhadh +Name[gl]=Aviso +Name[gu]=ચેતવણી +Name[he]=אזהרה +Name[hi]=चेतावनी +Name[hne]=चेतावनी +Name[hr]=Upozorenje +Name[hsb]=Kedźbu +Name[hu]=Figyelmeztetés +Name[ia]=Aviso +Name[id]=Peringatan +Name[is]=Aðvörun +Name[it]=Avviso +Name[ja]=警告 +Name[kk]=Ескерту +Name[km]=ការ​ព្រមាន +Name[kn]=ಎಚ್ಚರಿಕೆ +Name[ko]=경고 +Name[ku]=Hişyarî +Name[lt]=Dėmesio +Name[lv]=Brīdinājums +Name[mai]=चेतावनी +Name[mk]=Предупредување +Name[ml]=മുന്നറിയിപ്പു് +Name[mr]=इशारा +Name[nb]=Advarsel +Name[nds]=Wohrschoen +Name[ne]=चेतावनी +Name[nl]=Waarschuwing +Name[nn]=Åtvaring +Name[oc]=Alèrta +Name[or]=ଚେତାବନୀ +Name[pa]=ਚੇਤਾਵਨੀ +Name[pl]=Ostrzeżenie +Name[pt]=Aviso +Name[pt_BR]=Aviso +Name[ro]=Atenționare +Name[ru]=Предупреждение +Name[se]=Várrehus +Name[si]=අවවාදය +Name[sk]=Varovanie +Name[sl]=Opozorilo +Name[sr]=Упозорење +Name[sr@ijekavian]=Упозорење +Name[sr@ijekavianlatin]=Upozorenje +Name[sr@latin]=Upozorenje +Name[sv]=Varning +Name[ta]=எச்சரிக்கை +Name[te]=హెచ్చరిక +Name[tg]=Огоҳинома +Name[th]=คำเตือน +Name[tr]=Uyarı +Name[ug]=ئاگاھلاندۇرۇش +Name[uk]=Попередження +Name[uz]=Ogohnoma +Name[uz@cyrillic]=Огоҳнома +Name[vi]=Cảnh báo +Name[wa]=Adviertixhmint +Name[x-test]=xxWarningxx +Name[zh_CN]=警告 +Name[zh_TW]=警告 +Comment=Used for warning notifications +Comment[ar]=يُستخدَم لإخطارات التحذير +Comment[be@latin]=Dla aścierahalnych paviedamleńniaŭ +Comment[bg]=Използва се за предупреждения +Comment[bn]=সতর্কীকরণ বিজ্ঞপ্তির জন্য ব্যবহৃত হয় +Comment[bs]=Koristi se za obavještenja o upozorenjima +Comment[ca]=S'usa per a les notificacions d'avís +Comment[ca@valencia]=S'usa per a les notificacions d'avís +Comment[cs]=Použito pro varování a upozornění +Comment[da]=Bruges til advarselsbekendtgørelser +Comment[de]=Verwendet für Warnmeldungen +Comment[el]=Χρησιμοποιείται για τις προειδοποιήσεις +Comment[en_GB]=Used for warning notifications +Comment[eo]=Uzita por avertmesaĝoj +Comment[es]=Usado para notificaciones de advertencia +Comment[et]=Hoiatuste jaoks +Comment[eu]=Abisu-jakinarazpenetarako erabiltzen da +Comment[fi]=Käytetään varoitusilmoituksiin +Comment[fr]=Utilisé pour les notifications d'avertissements +Comment[fy]=Brûkt faor warskôging notifikaasjes +Comment[ga]=Úsáidte do rabhaidh +Comment[gl]=Emprégase para as notificacións de aviso +Comment[gu]=ચેતવણી નોંધણીઓ આપવા માટે વપરાય છે +Comment[he]=משמש להתרעות אזהרה +Comment[hi]=चेतावनियाँ देने के लिए उपयोग में लिया जाता है +Comment[hne]=चेतावनी सूचना बर उपयोग होथे +Comment[hr]=Korišten za upozoravajuće obavijesti +Comment[hu]=Kezelőprogram figyelmeztető üzenetekhez +Comment[ia]=Usate pro notificationes de avisos +Comment[id]=Digunakan untuk notifikasi peringatan +Comment[is]=Notað fyrir aðvaranir +Comment[it]=Usato per notifiche di avviso +Comment[ja]=警告の通知に使用 +Comment[kk]=Ескерту хабарларға қолданылады +Comment[km]=បានប្រើ​សម្រាប់​ការ​ជូន​ព្រមាន +Comment[kn]=ಎಚ್ಚರಿಕೆ ಸೂಚನೆಗಳಿಗೆ ಬಳಸಲಾಗುತ್ತದೆ +Comment[ko]=경고 알림에 사용됨 +Comment[lt]=Naudojama perspėjimams +Comment[lv]=Izmanto brīdinājumu paziņojumiem +Comment[ml]=താക്കീത് അറിയിപ്പുകള്‍ക്കായി ഉപയോഗിക്കുന്നു +Comment[mr]=इशारा सूचना करिता वापरले जाते +Comment[nb]=Brukt til varselsmeldinger +Comment[nds]=Bi Wohrschoen bruukt +Comment[nl]=Wordt gebruikt voor waarschuwingsmeldingen +Comment[nn]=Er brukt til åtvaringsvarsel +Comment[or]=ଚେତାବନୀ ବିଜ୍ଞପ୍ତିଗୁଡ଼ିକ ପାଇଁ ବ୍ୟବହୃତ ହୋଇଥାଏ +Comment[pa]=ਚੇਤਾਵਨੀ ਨੋਟੀਫਿਕੇਸ਼ਨ ਲਈ ਵਰਤਿਆ ਜਾਂਦਾ ਹੈ +Comment[pl]=Używane do ostrzeżeń +Comment[pt]=Usado para as notificações de aviso +Comment[pt_BR]=Usado para as notificações de aviso +Comment[ro]=Utilizat pentru notificări de avertizare +Comment[ru]=Используется для системных уведомлений +Comment[si]=අවවාද පණිවුඩ සඳහා යොදාගනී +Comment[sk]=Používa sa pre varovné upozornenia +Comment[sl]=Uporabljeno za obvestila z opozorili +Comment[sr]=Користи се за позорна обавештења +Comment[sr@ijekavian]=Користи се за позорна обавјештења +Comment[sr@ijekavianlatin]=Koristi se za pozorna obavještenja +Comment[sr@latin]=Koristi se za pozorna obaveštenja +Comment[sv]=Används för varningsmeddelanden +Comment[ta]=Used for warning notifications +Comment[te]=హెచ్చరిక నోటీసుల కొరకు వుపయోగించబడింది +Comment[tg]=Используется для надписей под значками на рабочем столе. +Comment[th]=ใช้สำหรับการแจ้งเตือนให้ทราบ +Comment[tr]=Uyarı bildirimleri için kullanılır +Comment[ug]=ئاگاھلاندۇرۇش ئۇقتۇرۇشلىرى ئۈچۈن ئىشلىتىلىدۇ. +Comment[uk]=Використовується для попереджень +Comment[vi]=Sử dụng cho thông tin cảnh báo +Comment[wa]=Eployî po des notifiaedjes d' adviertixhmint +Comment[x-test]=xxUsed for warning notificationsxx +Comment[zh_CN]=用于发出警告通知 +Comment[zh_TW]=用於警告通知 + +[Event/freememorynotif] +Name=Running low on disk space +Name[ar]=مساحة القرص منخفضة +Name[bg]=Дисковото пространство е твърде малко +Name[bn]=ডিস্ক-এ বেশী জায়গা বাকি নেই +Name[bs]=Ponestaje prostora na disku +Name[ca]=S'està exhaurint l'espai del disc +Name[ca@valencia]=S'està exhaurint l'espai del disc +Name[cs]=Dochází místo na disku +Name[da]=Ved at løbe tør for diskplads +Name[de]=Speicherplatz wird knapp +Name[el]=Τρέχον χωρητικότητα δίσκου χαμηλή +Name[en_GB]=Running low on disk space +Name[es]=Queda poco espacio en disco +Name[et]=Kettaruumi napib +Name[eu]=Leku gutxi gelditzen da diskoan +Name[fi]=Levytila alkaa olla lopussa +Name[fr]=L'espace disque commence à manquer +Name[ga]=Tá an diosca ag éirí lán +Name[gl]=Esgotando o espazo no disco +Name[he]=השטח הפנוי בדיסק מועט +Name[hi]=डिस्क में जगह कम हो गया है +Name[hr]=Ponestajanje diskovnog prostora +Name[hu]=Kezd fogyni a lemezterület +Name[ia]=Exhauriente le spatio de disco +Name[id]=Berjalan pada ruang kosong yang tinggal sedikit +Name[is]=Lítið pláss eftir á diski +Name[it]=Lo spazio su disco si sta esaurendo +Name[ja]=ディスクの空き領域が少ないです +Name[kk]=Диск орын тапшылығы +Name[km]=ដំណើរការ​ទាប​លើ​ទំហំ​ថាស +Name[kn]=ಮುದ್ರಿಕೆಯಲ್ಲಿ (ಡಿಸ್ಕ್) ಜಾಗ ಕಮ್ಮಿಯಾಗುತ್ತಿದೆ. +Name[ko]=디스크 공간 거의 없음 +Name[lt]=Diske liko mažai vietos +Name[lv]=Ir palicis maz brīvas vietas +Name[mr]=डिस्कवर कमी जागा शिल्लक आहे +Name[nb]=Det er nå lite diskplass +Name[nds]=De free Ruum op de Fastplaat geiht op de Neeg. +Name[nl]=Bijna geen vrije schijfruimte meer +Name[nn]=Det er lite diskplass att +Name[pa]=ਡਿਸਕ ਥਾਂ ਖਤਮ ਹੋ ਰਹੀ ਹੈ +Name[pl]=Zaczyna brakować miejsca na dysku +Name[pt]=Pouco espaço livre em disco +Name[pt_BR]=Pouco espaço livre em disco +Name[ro]=Spațiu pe disc este scăzut +Name[ru]=Недостаточно места на диске +Name[si]=පහත් තැටි ඉඩෙන් ධාවනය කරමි +Name[sk]=Dochádza voľné miesto na disku +Name[sl]=Razpoložljivega prostora na disku je malo +Name[sr]=Понестаје простора на диску +Name[sr@ijekavian]=Понестаје простора на диску +Name[sr@ijekavianlatin]=Ponestaje prostora na disku +Name[sr@latin]=Ponestaje prostora na disku +Name[sv]=Diskutrymmet håller på att ta slut +Name[th]=พื้นที่ดิสก์กำลังเหลือน้อย +Name[tr]=Düşük disk alanı üzerinde çalışıyor +Name[ug]=دىسكىدىكى بوشلۇق ئاز ھالەتتە ئىجرا قىلىۋاتىدۇ +Name[uk]=Замало місця на диску +Name[vi]=Không gian đĩa trống sắp hết +Name[wa]=Gn a pus bråmint d' plaece sol plake +Name[x-test]=xxRunning low on disk spacexx +Name[zh_CN]=磁盘空间过低 +Name[zh_TW]=磁碟空間快用完了 +Comment=You are running low on disk space +Comment[ar]=أنت تعمل على مساحة قرص منخفضة +Comment[bg]=Дисковото Ви пространство е твърде малко +Comment[bn]=আপনার ডিস্ক-এ বেশী জায়গা বাকি নেই +Comment[bs]=Ponestaje vam prostora na disku +Comment[ca]=L'espai del disc s'està exhaurint +Comment[ca@valencia]=L'espai del disc s'està exhaurint +Comment[cs]=Dochází vám místo na disku +Comment[da]=Du er ved at løbe tør for diskplads +Comment[de]=Ihr freier Speicherplatz wird knapp +Comment[el]=Η τρέχουσα χωρητικότητα του δίσκου σας είναι χαμηλή +Comment[en_GB]=You are running low on disk space +Comment[es]=Se está quedando sin espacio en disco +Comment[et]=Kettaruumi on vähe järele jäänud +Comment[eu]=Diskoan lekurik gabe gelditzen ari zara +Comment[fi]=Levytilasi alkaa loppua +Comment[fr]=Vous manquez d'espace disque +Comment[ga]=Tá an diosca ag éirí lán +Comment[gl]=Está a quedar sen espazo no disco +Comment[he]=השטח הפנוי בדיסק מתמעט +Comment[hi]=आप कम डिस्क जगह पर चल रहे हैं +Comment[hr]=Ponestaje vam diskovnog prostora +Comment[hu]=A lemezterület kezd elfogyni +Comment[ia]=Tu es exhauriente le spatio de disco +Comment[id]=Anda berjalan pada ruang kosong yang tinggal sedikit +Comment[is]=Þú ert að verða uppiskroppa með diskpláss +Comment[it]=Stai esaurendo lo spazio su disco +Comment[ja]=ディスクの空き領域が少なくなりました +Comment[kk]=Диск орын тапшылықтасыз +Comment[km]=អ្នក​កំពុង​ដំណើរការ​ទាប​​លើ​ទំហំ​ថាស +Comment[kn]=ನಿಮ್ಮಲ್ಲಿ ಕಡಿಮೆ ಡಿಸ್ಕ್‍ ಸ್ಥಳವಿದೆ +Comment[ko]=디스크 공간이 거의 없습니다 +Comment[lt]=Jūsų diske liko mažai vietos +Comment[lv]=Uz diska ir maz brīvas vietas +Comment[mr]=तुमच्या डिस्कवर कमी जागा शिल्लक आहे +Comment[nb]=Du har lite diskplass igjen +Comment[nds]=De free Ruum op Dien Fastplaat geiht op de Neeg. +Comment[nl]=U hebt bijna geen vrije schijfruimte meer +Comment[nn]=Du har lite diskplass att +Comment[pa]=ਤੁਹਾਡੇ ਕੋਲ ਡਿਸਕ ਖਾਲੀ ਥਾਂ ਘੱਟ ਰਹੀ ਹੈ +Comment[pl]=Zaczyna brakować miejsca na dysku +Comment[pt]=Está a ficar com pouco espaço livre em disco +Comment[pt_BR]=Você tem pouco espaço livre em disco +Comment[ro]=Spațiul dumneavoastră de stocare este pe cale să se termine +Comment[ru]=На диске осталось мало свободного места +Comment[si]=ඔබගේ තැටි ඉඩ අඩු වෙමින් පවතී +Comment[sk]=Dochádza vám voľné miesto na disku +Comment[sl]=Na disku imate malo razpoložljivega prostora +Comment[sr]=Понестаје вам простора на диску +Comment[sr@ijekavian]=Понестаје вам простора на диску +Comment[sr@ijekavianlatin]=Ponestaje vam prostora na disku +Comment[sr@latin]=Ponestaje vam prostora na disku +Comment[sv]=Diskutrymmet håller på att ta slut +Comment[th]=คุณกำลังทำงานด้วยพื้นที่ดิสก์ที่เหลือน้อย +Comment[tr]=Düşük disk alanı üzerinde çalışıyorsunuz +Comment[ug]=دىسكىدىكى بوشلۇق ئاز ھالەتتە ئىجرا قىلىۋاتىسىز +Comment[uk]=На вашому диску залишилося замало місця +Comment[vi]=Bạn đang dùng sắp hết không gian đĩa +Comment[wa]=Vos estoz k' n' a pus bråmint d' plaece sol plake +Comment[x-test]=xxYou are running low on disk spacexx +Comment[zh_CN]=您现在的磁盘空间过低 +Comment[zh_TW]=您的磁碟空間快用完了 +Contexts=warningnot +Action=Popup Index: plasma-workspace/freememorynotifier/freememorynotifier_prefs_base.ui =================================================================== --- /dev/null +++ plasma-workspace/freememorynotifier/freememorynotifier_prefs_base.ui @@ -0,0 +1,94 @@ + + + freememorynotifier_prefs_base + + + + 0 + 0 + 326 + 217 + + + + + + + % + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + false + + + Enable low memory space warning + + + true + + + + + + + Warn when free memory is below: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + + kcfg_enableNotification + toggled(bool) + kcfg_minimumSpace + setEnabled(bool) + + + 114 + 15 + + + 272 + 44 + + + + + kcfg_enableNotification + toggled(bool) + label_minimumSpace + setEnabled(bool) + + + 114 + 15 + + + 114 + 44 + + + + + Index: plasma-workspace/freememorynotifier/kcm_freememorynotifier.h =================================================================== --- /dev/null +++ plasma-workspace/freememorynotifier/kcm_freememorynotifier.h @@ -0,0 +1,52 @@ +/* This file is part of the KDE Project + Copyright (c) 2018 Oleg Solovyov + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#ifndef _KCM_FREEMEMORYNOTIFIER_H_ +#define _KCM_FREEMEMORYNOTIFIER_H_ + +#include +#include "ui_freememorynotifier_prefs_base.h" + +static const char CONFIG_ENABLE_NOTIFICATION[] = "enableNotification"; +static const char CONFIG_THRESHOLD[] = "threshold"; + +class KCMFreeMemoryModuleForm : public QWidget, public Ui::freememorynotifier_prefs_base +{ + Q_OBJECT + +public: + explicit KCMFreeMemoryModuleForm(QWidget* parent); +}; + +class KCMFreeMemoryModule : public KCModule +{ + Q_OBJECT + +public: + KCMFreeMemoryModule(QWidget *parent, const QVariantList&); + ~KCMFreeMemoryModule(); + +public slots: + void save() override; + void load() override; + void defaults() override; + +private: + KCMFreeMemoryModuleForm* m_ui; +}; + +#endif // _KCM_FREEMEMORYNOTIFIER_H_ Index: plasma-workspace/freememorynotifier/kcm_freememorynotifier.cpp =================================================================== --- /dev/null +++ plasma-workspace/freememorynotifier/kcm_freememorynotifier.cpp @@ -0,0 +1,102 @@ +/* This file is part of the KDE Project + Copyright (c) 2018 Oleg Solovyov + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#include "kcm_freememorynotifier.h" + +#include +#include +#include +#include + +#include + +K_PLUGIN_FACTORY_WITH_JSON(KCMFreeMemoryModuleFactory, + "kcm_freememorynotifier.json", + registerPlugin();) + +KCMFreeMemoryModuleForm::KCMFreeMemoryModuleForm(QWidget *parent) + : QWidget(parent) +{ + setupUi(this); +} + + +KCMFreeMemoryModule::KCMFreeMemoryModule(QWidget *parent, const QVariantList&) + : KCModule(parent) +{ + m_ui = new KCMFreeMemoryModuleForm(this); + + QGridLayout* layout = new QGridLayout(this); + layout->addWidget(m_ui, 0, 0); + + load(); +} + +KCMFreeMemoryModule::~KCMFreeMemoryModule() +{ +} + +void KCMFreeMemoryModule::load() +{ + KCModule::load(); + + KSharedConfig::Ptr cfg = KSharedConfig::openConfig(QStringLiteral("memorynotifierrc")); + KConfigGroup grp = cfg->group("General"); + + m_ui->kcfg_enableNotification->setChecked(grp.readEntry(CONFIG_ENABLE_NOTIFICATION, true)); + m_ui->kcfg_minimumSpace->setValue(grp.readEntry(CONFIG_THRESHOLD, 10)); + + connect(m_ui->kcfg_enableNotification, SIGNAL(stateChanged(int)), this, SLOT(changed())); + connect(m_ui->kcfg_minimumSpace, SIGNAL(valueChanged(int)), this, SLOT(changed())); + + emit changed(false); +} + +void KCMFreeMemoryModule::save() +{ + KCModule::save(); + + KSharedConfig::Ptr cfg = KSharedConfig::openConfig(QStringLiteral("memorynotifierrc")); + KConfigGroup grp = cfg->group("General"); + + grp.writeEntry(CONFIG_ENABLE_NOTIFICATION, m_ui->kcfg_enableNotification->isChecked()); + grp.writeEntry(CONFIG_THRESHOLD, m_ui->kcfg_minimumSpace->value()); + grp.sync(); + + QDBusConnection con = QDBusConnection::sessionBus(); + QDBusConnectionInterface* interface = con.interface(); + QDBusMessage msg = QDBusMessage::createMethodCall(QStringLiteral("org.kde.kded5"), + QStringLiteral("/modules/freememorynotifier"), + QStringLiteral("org.kde.FreeMemoryNotifier"), + QStringLiteral("reload")); + + con.asyncCall(msg); + + emit changed(false); +} + +void KCMFreeMemoryModule::defaults() +{ + KCModule::defaults(); + + m_ui->kcfg_enableNotification->setChecked(true); + m_ui->kcfg_minimumSpace->setValue(10); + + emit changed(true); +} + +#include "kcm_freememorynotifier.moc" Index: plasma-workspace/freememorynotifier/kcm_freememorynotifier.desktop =================================================================== --- /dev/null +++ plasma-workspace/freememorynotifier/kcm_freememorynotifier.desktop @@ -0,0 +1,134 @@ +[Desktop Entry] +Exec=kcmshell5 freememorynotifier +Icon=partitionmanager +Type=Service + +X-KDE-System-Settings-Parent-Category=desktopbehavior +X-KDE-ParentApp=kcontrol +X-KDE-ServiceTypes=KCModule +X-KDE-Library=kcm_freememorynotifier + +Name=Free Memory Notifier +Name[ar]=مُخطِر المساحة الحرّة +Name[bg]=Уведомяване за свободно пространство +Name[bs]=Izvještač o slobodnom prostoru +Name[ca]=Notificador d'espai lliure +Name[ca@valencia]=Notificador d'espai lliure +Name[cs]=Oznamování volného místa +Name[da]=Bekendtgørelse om ledig plads +Name[de]=Speicherplatzbenachrichtigung +Name[el]=Ειδοποίηση ελεύθερου χώρου +Name[en_GB]=Free Space Notifier +Name[es]=Notificador de espacio libre +Name[et]=Vaba ruumi teavitaja +Name[eu]=Leku askearen jakinarazlea +Name[fi]=Vapaan tilan ilmoitin +Name[fr]=Notification d'espace libre +Name[ga]=Fógróir Spáis Shaoir +Name[gl]=Notificador de espazo libre +Name[he]=Free Space Notifier +Name[hi]=खाली स्थान सूचक +Name[hr]=Glasnik slobodnog prostora +Name[hu]=Szabad hely értesítő +Name[ia]=Notificator de spatio libere +Name[id]=Notifikasi Ruang Kosong +Name[is]=Tilkynningar um laust pláss +Name[it]=Notificatore dello spazio libero +Name[ja]=空き領域の通知 +Name[kk]=KDE-нің бос орын туралы құлақтандыруы +Name[km]=កម្មវិធី​ជូនដំណឹង​​ទំហំ​ទំនេរ +Name[kn]=ಖಾಲಿ ಜಾಗ ಸೂಚಕ +Name[ko]=남은 공간 알림이 +Name[lt]=Laisvos vietos pranešėjas +Name[lv]=Brīvās vietas ziņotājs +Name[ml]=ലഭ്യമായ സ്ഥലം അറിയിക്കുന്നതിനുള്ള സംവിധാനം +Name[mr]=मोकळी जागा निदर्शक +Name[nb]=Ledig plass-varsler +Name[nds]=Freeruumbescheden +Name[nl]=Vrije ruimte-melder +Name[nn]=Varsel om lite ledig plass +Name[pa]=ਖਾਲੀ ਥਾਂ ਨੋਟੀਫਾਇਰ +Name[pl]=Powiadomienie o wolnym miejscu +Name[pt]=Notificação de Espaço Livre +Name[pt_BR]=Notificação de espaço livre +Name[ro]=Notificare spațiu liber +Name[ru]=Слежение за памятью +Name[si]=හිස් ඉඩ දැනුම් දෙන්නා +Name[sk]=Monitor voľného miesta +Name[sl]=Obvestilnik o neporabljenem prostoru +Name[sr]=Извештавач о слободном простору +Name[sr@ijekavian]=Извјештавач о слободном простору +Name[sr@ijekavianlatin]=Izvještavač o slobodnom prostoru +Name[sr@latin]=Izveštavač o slobodnom prostoru +Name[sv]=Information om ledigt utrymme +Name[th]=ตัวแจ้งพื้นที่ว่าง +Name[tr]=Boş Alan Bildirici +Name[ug]=بىكار بوشلۇق خەۋەرچىسى +Name[uk]=Сповіщення про вільне місце +Name[vi]=Trình thông báo không gian trống +Name[wa]=Notifieu del plaece di libe +Name[x-test]=xxFree Space Notifierxx +Name[zh_CN]=空闲空间通知器 +Name[zh_TW]=剩餘空間通知 +Comment=Out of memory notifier settings +Comment[ar]=يحذّرك عندما تنفذ مساحة مجلد المنزل +Comment[bg]=Предупреждение при твърде малко пространство в домашната директория +Comment[bn]=ব্যক্তিগত ফোল্ডারে জায়গা কমে গেলে সতর্ক করে +Comment[bs]=Upozorava kada vam ponestaje prostora u ličnom direktoriju +Comment[ca]=Avisa quan s'exhaureix l'espai de la carpeta personal +Comment[ca@valencia]=Avisa quan s'exhaureix l'espai de la carpeta personal +Comment[cs]=Varování při blížícím se nedostatku místa v domácí složce +Comment[da]=Advarer når du er ved at løbe tør for plads i din hjemmemappe +Comment[de]=Gibt eine Warnung aus, wenn der freie Speicherplatz in Ihrem Persönlichen Ordner knapp wird +Comment[el]=Προειδοποιεί όταν τελειώνει ο ελεύθερος χώρος στον 'Προσωπικό φάκελό' σας +Comment[en_GB]=Warns when running out of space on your home folder +Comment[es]=Le avisa cuando se está quedando sin espacio en su carpeta personal +Comment[et]=Hoiatus, kui kodukataloogis hakkab ruumi nappima +Comment[eu]=Abisua ematen du etxeko karpetan lekurik gabe gelditzen ari zarenean +Comment[fi]=Varoittaa kun kotikansiosta on tila loppumassa +Comment[fr]=Avertit lorsque l'espace vient à manquer dans votre dossier utilisateur +Comment[ga]=Tugann sé rabhadh duit nuair atá d'fhillteán baile ag éirí lán +Comment[gl]=Avisa cando se está a quedar sen espazo no cartafol persoal +Comment[he]=משמש לאזהרה כאשר המקום הפנוי בתיקיית הבית מועט +Comment[hr]=Upozori kada nestaje prostora u mojoj korisničkoj mapi +Comment[hu]=Figyelmeztet, ha kezd elfogyni a szabad lemezterület a saját könyvtárában +Comment[ia]=Il avisa quando il termina le spatio sur tu dossier domo +Comment[id]=Memperingatkan jika kehabisan ruang kosong di folder rumah anda +Comment[is]=Varar við þegar lítið pláss er eftir í heimamöppunni þinni +Comment[it]=Avvisa quando si sta esaurendo lo spazio nella tua cartella Home +Comment[ja]=ホームフォルダの空き領域が少なくなったとき警告します +Comment[kk]=Мекен қапшығыңызда орын тапшылығы туралы ескерту +Comment[km]=ព្រមាន នៅពេល​ដំណើរការ​អស់ទំហំ​នៅ​លើ​ក្នុង​​ផ្ទះ​របស់​អ្នក +Comment[kn]=ನೆಲೆ ಕೋಶದಲ್ಲಿ ಖಾಲಿ ಸ್ಥಳವು ಇದಕ್ಕಿಂತ ಕಡಿಮೆಯಾದರೆ ಎಚ್ಚರಿಸುತ್ತದೆ +Comment[ko]=홈 폴더에 공간이 없을 때 알려 줍니다 +Comment[lt]=Įspėja, kai namų aplanke baigiasi laisva vieta +Comment[lv]=Brīdina, kad mājas mapē beidzas brīvā vieta +Comment[mr]=तुमच्या मुख्य संचयीकेतील जागा संपत आल्याची सूचना देतो +Comment[nb]=Varsler når det er lite plass igjen i hjemmemappa +Comment[nds]=Wohrschoen bi to minn free Ruum binnen Dien Tohuusorner +Comment[nl]=Geeft een waarschuwing bij een lage stand van de vrije ruimte voor uw persoonlijke map +Comment[nn]=Varslar når det er lite plass i heimemappa +Comment[pa]=ਚੇਤਾਵਨੀ ਦਿਉ, ਜਦੋਂ ਤੁਹਾਡੇ ਘਰ ਫੋਲਡਰ ਉੱਤੇ ਥਾਂ ਖਤਮ ਹੋ ਰਹੀ ਹੋਵੇ +Comment[pl]=Ostrzega, kiedy zaczyna brakować miejsca w katalogu domowym +Comment[pt]=Avisa de estiver com falta de espaço na sua pasta pessoal +Comment[pt_BR]=Avisa quando ficar sem espaço na sua pasta pessoal +Comment[ro]=Atenționează când spațiul de stocare din dosarul acasă este pe cale să se termine +Comment[ru]=Параметры уведомлений о нехватке памяти +Comment[si]=ඔබගේ නිවාස බහාලුමේ ඉඩ අඩුවෙන් ධාවනය වෙන විට ඇනතුරු අඟවයි +Comment[sk]=Upozorňuje, keď dochádza voľné miesto v domovskom priečinku +Comment[sl]=Opozori, ko v domači mapi primanjkuje prostora +Comment[sr]=Упозорава када вам понестаје простора у домаћој фасцикли +Comment[sr@ijekavian]=Упозорава када вам понестаје простора у домаћој фасцикли +Comment[sr@ijekavianlatin]=Upozorava kada vam ponestaje prostora u domaćoj fascikli +Comment[sr@latin]=Upozorava kada vam ponestaje prostora u domaćoj fascikli +Comment[sv]=Varnar när utrymmet i hemkatalogen håller på att ta slut +Comment[th]=เตือนเมื่อพื้นที่ในโฟลเดอร์บ้านเหลือน้อย +Comment[tr]=Ev dizininizde boş alan azaldığı zaman uyarır +Comment[ug]=ماكان قىسقۇچىڭىزدىكى دىسكا بوشلۇقى ئاز قالغاندا ئەسكەرتىدۇ +Comment[uk]=Попереджає, якщо у домашній теці залишається мало місця +Comment[vi]=Cảnh báo khi sắp hết không gian cho thư mục chính của bạn +Comment[wa]=Advierti cwand i gn a cåzu pupont d' plaece dins vosse ridant måjhon +Comment[x-test]=xxWarns when running out of space on your home folderxx +Comment[zh_CN]=在您主目录磁盘空间过低时发出警告 +Comment[zh_TW]=當您的家目錄剩餘空間快不足時警告您 +Categories=Qt;KDE;X-KDE-settings-system; Index: plasma-workspace/freememorynotifier/module.h =================================================================== --- /dev/null +++ plasma-workspace/freememorynotifier/module.h @@ -0,0 +1,44 @@ +/* This file is part of the KDE Project + Copyright (c) 2006 Lukas Tinkl + Copyright (c) 2008 Lubos Lunak + Copyright (c) 2009 Ivo Anjo + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#ifndef MODULE_H +#define MODULE_H + +#include +#include +#include + +#include "freememorynotifier.h" + +class FreeMemoryNotifierModule + : public KDEDModule + { + Q_OBJECT + Q_CLASSINFO("D-Bus Interface", "org.kde.FreeMemoryNotifier") + public: + FreeMemoryNotifierModule(QObject* parent, const QList&); + + public Q_SLOTS: + Q_SCRIPTABLE Q_NOREPLY void reload(); + + private: + FreeMemoryNotifier notifier; + }; + +#endif Index: plasma-workspace/freememorynotifier/module.cpp =================================================================== --- /dev/null +++ plasma-workspace/freememorynotifier/module.cpp @@ -0,0 +1,37 @@ +/* This file is part of the KDE Project + Copyright (c) 2018 Oleg Solovyov + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#include "module.h" + +#include + +K_PLUGIN_FACTORY_WITH_JSON(FreeMemoryNotifierModuleFactory, + "freememorynotifier.json", + registerPlugin(); + ) + +FreeMemoryNotifierModule::FreeMemoryNotifierModule(QObject* parent, const QList&) + : KDEDModule(parent) +{ +} + +void FreeMemoryNotifierModule::reload() +{ + notifier.reload(); +} + +#include "module.moc" Index: plasma-workspace/freememorynotifier/org.kde.FreeMemoryNotifier.xml =================================================================== --- /dev/null +++ plasma-workspace/freememorynotifier/org.kde.FreeMemoryNotifier.xml @@ -0,0 +1,8 @@ + + + + + + + + Index: plasma-workspace/freememorynotifier/settings.kcfgc =================================================================== --- /dev/null +++ plasma-workspace/freememorynotifier/settings.kcfgc @@ -0,0 +1,6 @@ +# Code generation options for kconfig_compiler +File=freememorynotifier.kcfg +ClassName=FreeMemoryNotifierSettings +Singleton=true +Mutators=minimumSpace,enableNotification +# will create the necessary code for setting those variables Index: plasma-workspace/systemmonitor/ksystemactivitydialog.h =================================================================== --- plasma-workspace/systemmonitor/ksystemactivitydialog.h +++ plasma-workspace/systemmonitor/ksystemactivitydialog.h @@ -45,6 +45,7 @@ /** Set the text in the filter line in the process list widget */ void setFilterText(const QString &filterText); + void ignoreConfig(); QString filterText() const; /** Save the settings if the user presses the ESC key */ @@ -61,6 +62,7 @@ void saveDialogSettings(); KSysGuardProcessList m_processList; + bool m_ignoreConfig; }; #endif // not Q_WS_WIN Index: plasma-workspace/systemmonitor/ksystemactivitydialog.cpp =================================================================== --- plasma-workspace/systemmonitor/ksystemactivitydialog.cpp +++ plasma-workspace/systemmonitor/ksystemactivitydialog.cpp @@ -43,7 +43,7 @@ #include KSystemActivityDialog::KSystemActivityDialog(QWidget *parent) - : QDialog(parent), m_processList(0) + : QDialog(parent), m_processList(0), m_ignoreConfig(false) { setWindowTitle(i18n("System Activity")); setWindowIcon(QIcon::fromTheme(QStringLiteral( "utilities-system-monitor" ))); @@ -70,10 +70,35 @@ { resize(QSize(650, 420)); - KConfigGroup cg = KSharedConfig::openConfig()->group("TaskDialog"); - KWindowConfig::restoreWindowSize(windowHandle(), cg); + if (!m_ignoreConfig) { + qDebug() << "Settings was loaded from config"; + KConfigGroup cg = KSharedConfig::openConfig()->group("TaskDialog"); + KWindowConfig::restoreWindowSize(windowHandle(), cg); + + m_processList.loadSettings(cg); + } else { + qDebug() << "Config was ignored, default settings were used"; + /* sort descending by memory, for some weird reason Qt::AscendingOrder is sorting descending and vice versa + * */ + m_processList.treeView()->sortByColumn(ProcessModel::HeadingMemory, Qt::AscendingOrder); + // show only own processes + m_processList.setState(ProcessFilter::State::OwnProcesses); + // hide "user" column + m_processList.treeView()->hideColumn(ProcessModel::HeadingUser); + // show "kill" column + m_processList.treeView()->showColumn(ProcessModel::HeadingKillBtn); + // move "kill" button + m_processList.setKillButtonVisible(false); + + // resize columns + m_processList.treeView()->resizeColumnToContents(ProcessModel::HeadingMemory); + m_processList.treeView()->resizeColumnToContents(ProcessModel::HeadingName); + m_processList.treeView()->resizeColumnToContents(ProcessModel::HeadingKillBtn); + + // update every 2 seconds + m_processList.setUpdateIntervalMSecs(2000); + } - m_processList.loadSettings(cg); // Since we default to forcing the window to be KeepAbove, if the user turns this off, remember this const bool keepAbove = true; // KRunnerSettings::keepTaskDialogAbove(); if (keepAbove) { @@ -112,14 +132,16 @@ void KSystemActivityDialog::closeEvent(QCloseEvent *event) { - saveDialogSettings(); + if (!m_ignoreConfig) + saveDialogSettings(); event->accept(); } void KSystemActivityDialog::reject () { - saveDialogSettings(); + if (!m_ignoreConfig) + saveDialogSettings(); QDialog::reject(); } @@ -137,5 +159,10 @@ KSharedConfig::openConfig()->sync(); } +void KSystemActivityDialog::ignoreConfig() +{ + m_ignoreConfig = true; +} + #endif // not Q_WS_WIN Index: plasma-workspace/systemmonitor/main.cpp =================================================================== --- plasma-workspace/systemmonitor/main.cpp +++ plasma-workspace/systemmonitor/main.cpp @@ -20,6 +20,9 @@ #include #include #include +#include +#include +#include #include "ksystemactivitydialog.h" @@ -38,5 +41,19 @@ } KSystemActivityDialog dialog; + + QCommandLineParser cliOptions; + QCommandLineOption ignOption(QStringList() << QStringLiteral("i") << + QStringLiteral("ignore-config"), + i18n("Disable config file")); + + cliOptions.addOption(ignOption); + cliOptions.process(app); + + if (cliOptions.isSet(ignOption)) { + dialog.ignoreConfig(); + qDebug() << "The config will be ignored"; + } + return dialog.exec(); }