commit 8ffa31394eb0189f76598d68f1ac2f8cbb3ad8ab Author: eSh Date: Fri Sep 16 01:14:20 2022 +0200 initial commit diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..9a3bf4a --- /dev/null +++ b/Makefile @@ -0,0 +1,12 @@ +# makefile for tromjaro fixes package +build: + makepkg + +install: + pamac-installer tromjaro-fixes-*.tar.xz + +remove: + pamac-installer --remove tromjaro-fixes + +clean: + $(RM) -rf src/ pkg/ *.tar.xz \ No newline at end of file diff --git a/PKGBUILD b/PKGBUILD new file mode 100644 index 0000000..18f911f --- /dev/null +++ b/PKGBUILD @@ -0,0 +1,30 @@ +# Maintainer: TROM +pkgname=tromjaro-fixes +pkgver=1.0.0 +pkgrel=1 +pkgdesc="Various fixes for TROMjaro OS" +arch=(any) +url="" +license=(unknown) +depends=() +provides=('tromjaro-fixes') +backup=() +options=(!strip) +install='fixes-package.install' +source=() +sha256sums=('SKIP') +package() { + # copy scripts + install -Dm755 bin/standalone/* ${pkgdir}/usr/bin + install -Dm755 bin/periodic/* ${pkgdir}/usr/bin + + # copy systemd units + install -Dm644 systemd/services/* ${pkgdir}/usr/lib/systemd/system + install -Dm644 systemd/timers/* ${pkgdir}/usr/lib/systemd/system + + # copy alpm hooks + install -Dm644 alpm-hooks/* ${pkgdir}/usr/share/libalpm/hooks + + # copy flatpak overrides + install -Dm644 flatpak-overrides/* ${pkgdir}/var/lib/flatpak/overrides +} diff --git a/README.md b/README.md new file mode 100644 index 0000000..f963cd1 --- /dev/null +++ b/README.md @@ -0,0 +1,21 @@ +# TROMjaro fixes package + +Various fixes for TROMjaro OS + +## Building the package + +Open Terminal and issue the command: + +`make` + +To install the package right after the building, use: + +`make install` + +To remove just installed package, use: + +`make remove` + +To cleanup the project, use: + +`make clean` diff --git a/alpm-hooks/chaotic-keyring-refresh.hook b/alpm-hooks/chaotic-keyring-refresh.hook new file mode 100644 index 0000000..d55dddc --- /dev/null +++ b/alpm-hooks/chaotic-keyring-refresh.hook @@ -0,0 +1,11 @@ +[Trigger] +Operation = Upgrade +Operation = Remove +Operation = Install +Type = Package +Target = * + +[Action] +Description = Refreshing the chaotic-aur keyring... +When = PreTransaction +Exec = /usr/bin/chaotic-keyring-refresh \ No newline at end of file diff --git a/alpm-hooks/reinstall-for-qt.hook b/alpm-hooks/reinstall-for-qt.hook new file mode 100644 index 0000000..7fb0f94 --- /dev/null +++ b/alpm-hooks/reinstall-for-qt.hook @@ -0,0 +1,11 @@ +[Trigger] +Operation = Upgrade +Type = Package +Target = qt5-base +Target = qt6-base + + +[Action] +Description = Reinstalling needed packages for theming QT applications... +When = PostTransaction +Exec = /usr/bin/reinstall-for-qt \ No newline at end of file diff --git a/bin/periodic/fix-flatpaks-theming b/bin/periodic/fix-flatpaks-theming new file mode 100755 index 0000000..d0e973c --- /dev/null +++ b/bin/periodic/fix-flatpaks-theming @@ -0,0 +1,4 @@ +#!/bin/sh +rm -r ~/.themes/* 2> /dev/null +rsync -av --progress /usr/share/themes/* ~/.themes/ --exclude Windowck +rsync -av --progress ~/.local/share/themes/* ~/.themes/ --exclude Windowck-dark diff --git a/bin/periodic/fix-theming b/bin/periodic/fix-theming new file mode 100755 index 0000000..6ca6ff0 --- /dev/null +++ b/bin/periodic/fix-theming @@ -0,0 +1,34 @@ +#!/bin/sh +sync_theme() { + # Get the current system theme + theme=$(xfconf-query -c xsettings -p /Net/ThemeName) + # Find the best match for the xfwm4 theme that corresponds with the current system theme + xfwm4_theme=$(find /usr/share/themes/ /usr/local/share/themes/ "$HOME"/.themes/ "$HOME"/.local/share/themes/ -mindepth 2 -maxdepth 2 -type d -name xfwm4 -printf '%h\n' 2>/dev/null | grep -o "/${theme}[^/]*$" | sort | head -n1) + # If a match is not found then use the Default theme + [ -z "$xfwm4_theme" ] && xfwm4_theme='Default' + # Apply the xfwm4 theme + xfconf-query -c xfwm4 -p /general/theme -n -t string -s "${xfwm4_theme#/}" + # Apply the current theme with gsettings + gsettings set org.gnome.desktop.interface gtk-theme "$theme" +} +sync_icon_theme() { + # Get the current icon theme + icon_theme=$(xfconf-query -c xsettings -p /Net/IconThemeName) + # Apply the same theme in qt5ct and qt6ct configuration + sed -i "s/^icon_theme=.*$/icon_theme=$icon_theme/" "$HOME"/.config/qt5ct/qt5ct.conf + sed -i "s/^icon_theme=.*$/icon_theme=$icon_theme/" "$HOME"/.config/qt6ct/qt6ct.conf +} + +# Get the current system theme +theme_new=$(xfconf-query -c xsettings -p /Net/ThemeName) +# Get the current icon theme +icon_theme_new=$(xfconf-query -c xsettings -p /Net/IconThemeName) + +# Run sync_theme if the new system theme doesn't match the previous one +[ "$theme_new" != "$theme_prev" ] && sync_theme +# Run sync_icon_theme if the new icon theme doesn't match the previous one +[ "$icon_theme_new" != "$icon_theme_prev" ] && sync_icon_theme + +# The new values become the previous values +theme_prev=$theme_new +icon_theme_prev=$icon_theme_new diff --git a/bin/periodic/fix-tweaked-desktop-files b/bin/periodic/fix-tweaked-desktop-files new file mode 100755 index 0000000..9ebc42f --- /dev/null +++ b/bin/periodic/fix-tweaked-desktop-files @@ -0,0 +1,86 @@ +#!/bin/bash +pidof -sq -o %PPID -x "$(basename "$0")" && exit +data="$HOME"/.local/share/applications/tweaked-desktop-files +data2="$HOME"/.local/share/applications/bakkedup-desktop-files + +# Directories where desktop files are stored +user="$HOME"/.local/share/applications +flatpak_local="$HOME"/.local/share/flatpak/exports/share/applications +flatpak_global=/var/lib/flatpak/exports/share/applications +pacman_local=/usr/local/share/applications +pacman_global=/usr/share/applications +snap=/var/lib/snapd/desktop/applications + +detectfiles() { + for file in "$user"/*.desktop; do + name=$(basename "$file") || continue + [ -d "$file" ] || grep -xq "\(flatpak-local\|flatpak-global\|pacman-local\|pacman-global\|snap\)/$name" "$data" && continue + if [ -f "$flatpak_local/$name" ]; then + echo "flatpak-local/$name" >> "$data" + elif [ -f "$flatpak_global/$name" ]; then + echo "flatpak-global/$name" >> "$data" + elif [ -f "$pacman_local/$name" ]; then + echo "pacman-local/$name" >> "$data" + elif [ -f "$pacman_global/$name" ]; then + echo "pacman-global/$name" >> "$data" + elif [ -f "$snap/$name" ]; then + echo "snap/$name" >> "$data" + fi + done +} + +fixfiles() { + lastmod=$(stat -c "%Y" "$data") + tmp="$(mktemp)" + trap 'rm $tmp' EXIT + [ -f "$data" ] && cp "$data" "$tmp" && copied='true' + lineno=0 + [ "$copied" = 'true' ] && while IFS= read -r line; do + ((lineno++)) + name=${line#*/} + file="$user/$name" + # shellcheck disable=2015 # To disable shellcheck error here, line below is intended to work this way + echo "$line" | grep -xq '\(flatpak-local\|flatpak-global\|pacman-local\|pacman-global\|snap\)/.\+' && [ -f "$file" ] || { sed -i "${lineno}d" "$tmp" && ((lineno--)) ; continue; } + [ -f "$flatpak_local/$name" ] || + [ -f "$flatpak_global/$name" ] || + [ -f "$pacman_local/$name" ] || + [ -f "$pacman_global/$name" ] || + [ -f "$snap/$name" ] || + { mv "$file" "$file.bak" && echo "$line" >> "$data2"; } + done < "$data" + + [ "$copied" = 'true' ] && [ "$(stat -c '%Y' "$data")" = "$lastmod" ] && sort "$tmp" | uniq > "$data" + + [ -n "$(sort "$data2" | uniq -d)" ] && cp "$data2" "$tmp" && sort "$tmp" | uniq > "$data2" + + for bakfile in "$user"/*.desktop.bak; do + origfile="${bakfile%.bak}" + [ -f "$origfile" ] && continue + name=$(basename "$origfile") || continue + [ -f "$flatpak_local/$name" ] || + [ -f "$flatpak_global/$name" ] || + [ -f "$pacman_local/$name" ] || + [ -f "$pacman_global/$name" ] || + [ -f "$snap/$name" ] && + mv "$bakfile" "$origfile" + done +} + +user_new=$(ls -ad "$user"/*.desktop 2>/dev/null) +flatpak_local_new=$(ls -ad "$flatpak_local"/*.desktop 2>/dev/null) +flatpak_global_new=$(ls -ad "$flatpak_global"/*.desktop 2>/dev/null) +pacman_local_new=$(ls -ad "$pacman_local"/*.desktop 2>/dev/null) +pacman_global_new=$(ls -ad "$pacman_global"/*.desktop 2>/dev/null) +snap_new=$(ls -ad "$snap"/*.desktop 2>/dev/null) +[ "$user_new" != "$user_old" ] && detectfiles +[ "$flatpak_local_new" != "$flatpak_local_old" ] || + [ "$flatpak_global_new" != "$flatpak_global_old" ] || + [ "$pacman_local_new" != "$pacman_local_old" ] || + [ "$pacman_global_new" != "$pacman_global_old" ] || + [ "$snap_new" != "$snap_old" ] && fixfiles +user_old=$user_new +flatpak_local_old=$flatpak_local_new +flatpak_global_old=$flatpak_global_new +pacman_local_old=$pacman_local_new +pacman_global_old=$pacman_global_new +snap_old=$snap_new diff --git a/bin/standalone/app-finder b/bin/standalone/app-finder new file mode 100755 index 0000000..a3b18a8 --- /dev/null +++ b/bin/standalone/app-finder @@ -0,0 +1,2 @@ +#!/bin/bash +xdotool search --onlyvisible --class xfce4-appfinder windowkill || setsid -f xfce4-appfinder diff --git a/bin/standalone/fix-chaotic-keyring b/bin/standalone/fix-chaotic-keyring new file mode 100755 index 0000000..75d3196 --- /dev/null +++ b/bin/standalone/fix-chaotic-keyring @@ -0,0 +1,3 @@ +#!/bin/bash +sudo pacman-key --populate chaotic & +rm ~/.local/bin/fix-chaotic-keyring diff --git a/bin/standalone/reinstall-for-qt b/bin/standalone/reinstall-for-qt new file mode 100755 index 0000000..e0f1abf --- /dev/null +++ b/bin/standalone/reinstall-for-qt @@ -0,0 +1,3 @@ +#!/bin/bash +rm /var/lib/pacman/db.lck +pacman --noconfirm -S qt5-styleplugins qt6gtk2 diff --git a/fixes-package.install b/fixes-package.install new file mode 100644 index 0000000..5febd7f --- /dev/null +++ b/fixes-package.install @@ -0,0 +1,3 @@ +post_install() { + systemctl enable fix-*.timer +} diff --git a/flatpak-overrides/global b/flatpak-overrides/global new file mode 100644 index 0000000..4e047e9 --- /dev/null +++ b/flatpak-overrides/global @@ -0,0 +1,2 @@ +[Context] +filesystems=~/.themes; \ No newline at end of file diff --git a/systemd/services/fix-flatpaks-theming.service b/systemd/services/fix-flatpaks-theming.service new file mode 100644 index 0000000..e144dc8 --- /dev/null +++ b/systemd/services/fix-flatpaks-theming.service @@ -0,0 +1,13 @@ +# This service unit is for fix-flatpaks-theming script +# + +[Unit] +Description=Fix flatpak theming script +Wants=fix-flatpaks-theming.timer + +[Service] +Type=oneshot +ExecStart=/usr/bin/fix-flatpaks-theming + +[Install] +WantedBy=multi-user.target diff --git a/systemd/services/fix-theming.service b/systemd/services/fix-theming.service new file mode 100644 index 0000000..c82d37a --- /dev/null +++ b/systemd/services/fix-theming.service @@ -0,0 +1,13 @@ +# This service unit is for fix-theming script +# + +[Unit] +Description=Fix theming script +Wants=fix-theming.timer + +[Service] +Type=oneshot +ExecStart=/usr/bin/fix-theming + +[Install] +WantedBy=multi-user.target diff --git a/systemd/services/fix-tweaked-desktop-files.service b/systemd/services/fix-tweaked-desktop-files.service new file mode 100644 index 0000000..5fc7195 --- /dev/null +++ b/systemd/services/fix-tweaked-desktop-files.service @@ -0,0 +1,13 @@ +# This service unit is for fix-tweaked-desktop-files script +# + +[Unit] +Description=Fix tweaked desktop files script +Wants=fix-tweaked-desktop-files.timer + +[Service] +Type=oneshot +ExecStart=/usr/bin/fix-tweaked-desktop-files + +[Install] +WantedBy=multi-user.target diff --git a/systemd/timers/fix-flatpaks-theming.timer b/systemd/timers/fix-flatpaks-theming.timer new file mode 100644 index 0000000..614059c --- /dev/null +++ b/systemd/timers/fix-flatpaks-theming.timer @@ -0,0 +1,14 @@ +# This timer unit is for fix-flatpaks-theming service unit +# + +[Unit] +Description=Run fix flatpaks theming script every 600 seconds +Requires=fix-flatpaks-theming.service + +[Timer] +Unit=fix-flatpaks-theming.service +OnBootSec=1 +OnUnitActiveSec=600 + +[Install] +WantedBy=timers.target \ No newline at end of file diff --git a/systemd/timers/fix-theming.timer b/systemd/timers/fix-theming.timer new file mode 100644 index 0000000..7dd921f --- /dev/null +++ b/systemd/timers/fix-theming.timer @@ -0,0 +1,14 @@ +# This timer unit is for fix-theming service unit +# + +[Unit] +Description=Run fix theming script every 3 seconds +Requires=fix-theming.service + +[Timer] +Unit=fix-theming.service +OnBootSec=1 +OnUnitActiveSec=3 + +[Install] +WantedBy=timers.target \ No newline at end of file diff --git a/systemd/timers/fix-tweaked-desktop-files.timer b/systemd/timers/fix-tweaked-desktop-files.timer new file mode 100644 index 0000000..675a196 --- /dev/null +++ b/systemd/timers/fix-tweaked-desktop-files.timer @@ -0,0 +1,14 @@ +# This timer unit is for fix-tweaked-desktop-files service unit +# + +[Unit] +Description=Run fix tweaked desktop files script every 5 seconds +Requires=fix-tweaked-desktop-files.service + +[Timer] +Unit=ffix-tweaked-desktop-files.service +OnBootSec=1 +OnUnitActiveSec=5 + +[Install] +WantedBy=timers.target \ No newline at end of file