kwin: merge window rules into global rules config

prior to 93a4a9263b it was done by a
separate program (kwin_update_default_rules)

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
Ivailo Monev 2023-08-10 10:36:14 +03:00
parent 108f16a997
commit 96a522adbd
2 changed files with 16 additions and 38 deletions

View file

@ -33,39 +33,8 @@ setting Maximum size, changing it to Force and entering "1600,1200" as
the maximum size, which will make KWin force this size as the maximum size.
To create such window-specific setting automatically without a need of doing
it manually for every user (for example when doing a large deployment), follow
these steps:
- Back up your $KDEHOME/share/config/kwinrulesrc ($KDEHOME usually being $HOME/.kde)
and remove it
- Run 'dcop kwin default reconfigure'
- Create manually all window-specific settings that should be included (see above)
- When done, check in Window-specific settings configuration module
(Alt+F3/Configure window behavior/Window-specific settings) that all rules are
included
- Create a copy of $KDEHOME/share/config/kwinrulesrc and restore the original one
- Rename the copy (i.e. the newly created kwinrulesrc) to have its unique name
(e.g. foobar_fix_maxsize in this example case)
- Be careful with manual modifications of the file, especially make sure the count=
field in the [General] group is updated if needed
- Create a file for kconfig_update like this (named kwin_foobar_fix_maxsize.upd
in this example):
# kwin_foobar_fix_maxsize.upd start #
Id=foobar_fix_maxsize
File=kwinrules_update
Group=Dummy
Options=overwrite
ScriptArguments=foobar_fix_maxsize
Script=kwin_update_default_rules
# kwin_foobar_fix_maxsize.upd end #
- The kconfig_file (kwin_foobar_fix_maxsize.upd) is to be placed
in $KDEDIR/share/apps/kconf_update/
- The file with the window-specific settings (foobar_fix_maxsize) is to be placed
in $KDEDIR/share/apps/kwin/default_rules/
it manually for every user create file with the window-specific settings in
$KDEDIR/share/apps/kwin/default_rules/
All KDE user accounts should have these new window-specific settings added
automatically during next KDE startup (or within few seconds if they are active).

View file

@ -21,12 +21,13 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "rules.h"
#include <fixx11h.h>
#include <QRegExp>
#include <QFile>
#include <kconfig.h>
#include <KXMessages>
#include <QRegExp>
#include <ktemporaryfile.h>
#include <QFile>
#include <ktoolinvocation.h>
#include <kstandarddirs.h>
#ifndef KCMRULES
#include "client.h"
@ -973,13 +974,21 @@ void RuleBook::load()
deleteAll();
KConfig cfg("kwinrulesrc", KConfig::NoGlobals);
int count = cfg.group("General").readEntry("count", 0);
for (int i = 1;
i <= count;
++i) {
for (int i = 1; i <= count; ++i) {
KConfigGroup cg(&cfg, QString::number(i));
Rules* rule = new Rules(cg);
m_rules.append(rule);
}
const QStringList kwinrules = KGlobal::dirs()->findAllResources("data", "kwin/default_rules/*.kwinrules");
foreach (const QString &kwinrule, kwinrules) {
KConfig cfg(kwinrule, KConfig::NoGlobals);
int count = cfg.group("General").readEntry("count", 0);
for (int i = 1; i <= count; ++i) {
KConfigGroup cg(&cfg, QString::number(i));
Rules* rule = new Rules(cg);
m_rules.append(rule);
}
}
}
void RuleBook::save()