ajout wallpaper

This commit is contained in:
2025-12-28 09:35:23 +01:00
parent f94ba663f8
commit 7bd522ad01
8 changed files with 535 additions and 1 deletions

View File

@@ -3,6 +3,7 @@ import St from 'gi://St';
import Clutter from 'gi://Clutter';
import GObject from 'gi://GObject';
import Gio from 'gi://Gio';
import GLib from 'gi://GLib';
import * as PanelMenu from 'resource:///org/gnome/shell/ui/panelMenu.js';
import * as PopupMenu from 'resource:///org/gnome/shell/ui/popupMenu.js';
import * as Slider from 'resource:///org/gnome/shell/ui/slider.js';
@@ -555,6 +556,37 @@ class KeyboardRGBIndicator extends PanelMenu.Button {
return closestColor;
}
/**
* Change le fond d'écran en fonction de la couleur GNOME
*/
_changeWallpaper(accentColor) {
try {
// Construire le chemin absolu du wallpaper
const homeDir = GLib.get_home_dir();
const absolutePath = `${homeDir}/.local/share/gnome-shell/extensions/asus-kbd-rgb@gilles/wallpapers/ec_v_${accentColor}.jpg`;
// Vérifier si le fichier existe
const wallpaperFile = Gio.File.new_for_path(absolutePath);
if (!wallpaperFile.query_exists(null)) {
log(`[ASUS RGB] Fond d'écran non trouvé : ${absolutePath}`);
return;
}
// Appliquer le fond d'écran
const backgroundSettings = new Gio.Settings({
schema: 'org.gnome.desktop.background'
});
const uri = `file://${absolutePath}`;
backgroundSettings.set_string('picture-uri', uri);
backgroundSettings.set_string('picture-uri-dark', uri); // Pour le mode sombre
log(`[ASUS RGB] Fond d'écran changé → ${accentColor} (${absolutePath})`);
} catch (error) {
logError(error, '[ASUS RGB] Erreur lors du changement de fond d\'écran');
}
}
/**
* Synchronise la couleur du clavier avec le thème GNOME
*/
@@ -579,6 +611,9 @@ class KeyboardRGBIndicator extends PanelMenu.Button {
interfaceSettings.set_string('accent-color', accentColor);
log(`[ASUS RGB] Thème GNOME synchronisé → ${accentColor} (RGB: ${this._currentR}, ${this._currentG}, ${this._currentB})`);
// Changer le fond d'écran correspondant
this._changeWallpaper(accentColor);
} catch (error) {
logError(error, '[ASUS RGB] Erreur lors de la synchronisation du thème GNOME');
}