workstation/roles/common/templates/favorites.sh.j2

26 lines
1.0 KiB
Plaintext
Raw Normal View History

2021-12-06 05:57:07 +00:00
#!/bin/bash
FAVORITES="{% for item in favorites %}{{ item }}{{ ',' if not loop.last else '' }}{% endfor %}"
if [ -f ~/.config/kactivitymanagerd-statsrc ]; then
if ! grep -q "$FAVORITES" ~/.config/kactivitymanagerd-statsrc; then
sed -i "/^ordering/s/=.*/=$FAVORITES/" ~/.config/kactivitymanagerd-statsrc
fi
fi
2021-12-06 05:57:07 +00:00
sqlite3 ~/.local/share/kactivitymanagerd/resources/database <<-EOF
CREATE TEMPORARY TABLE FavoritesList (usedActivity TEXT, initiatingAgent TEXT, targettedResource TEXT);
INSERT INTO FavoritesList (usedActivity, initiatingAgent, targettedResource)
VALUES
{% for item in favorites %}
(":global", "org.kde.plasma.favorites.applications", "{{ item }}"){{ "," if not loop.last else ";" }}
{% endfor %}
INSERT INTO ResourceLink (usedActivity, initiatingAgent, targettedResource)
SELECT f.usedActivity, f.initiatingAgent, f.targettedResource
FROM FavoritesList AS f
WHERE f.targettedResource NOT IN (SELECT targettedResource FROM ResourceLink);
DELETE FROM ResourceLink
WHERE targettedResource NOT IN (SELECT targettedResource FROM FavoritesList);
EOF