@@ -587,4 +587,57 @@ export class ConfigWriter {
587587 console . error ( 'Error applying omarchy theme:' , e . message ) ;
588588 }
589589 }
590+
591+ applyWallpaper ( wallpaperPath ) {
592+ try {
593+ console . log ( 'Applying wallpaper from path:' , wallpaperPath ) ;
594+ if ( wallpaperPath ) {
595+ // Create symlink ~/.config/omarchy/current/background -> wallpaperPath
596+ const symlinkPath = GLib . build_filenamev ( [
597+ this . configDir ,
598+ 'omarchy' ,
599+ 'current' ,
600+ 'background' ,
601+ ] ) ;
602+ this . _createSymlink ( wallpaperPath , symlinkPath , 'wallpaper' ) ;
603+ GLib . spawn_command_line_async ( 'pkill -x swaybg' ) ;
604+ GLib . spawn_command_line_async ( `swaybg -i "${ wallpaperPath } " -m fill` ) ;
605+ }
606+ } catch ( e ) {
607+ console . error ( 'Error applying wallpaper:' , e . message ) ;
608+ }
609+ }
610+
611+ _createSymlink ( sourcePath , symlinkPath , label = 'symlink' ) {
612+ try {
613+ // Ensure parent directory exists
614+ const parentDir = GLib . path_get_dirname ( symlinkPath ) ;
615+ ensureDirectoryExists ( parentDir ) ;
616+
617+ // Remove existing symlink or file if it exists
618+ const symlinkFile = Gio . File . new_for_path ( symlinkPath ) ;
619+ if ( symlinkFile . query_exists ( null ) ) {
620+ try {
621+ symlinkFile . delete ( null ) ;
622+ console . log ( `Removed existing ${ label } symlink` ) ;
623+ } catch ( e ) {
624+ console . error ( `Error removing existing ${ label } symlink:` , e . message ) ;
625+ }
626+ }
627+
628+ // Create symlink
629+ try {
630+ const symlinkGFile = Gio . File . new_for_path ( symlinkPath ) ;
631+ symlinkGFile . make_symbolic_link ( sourcePath , null ) ;
632+ console . log ( `Created ${ label } symlink: ${ symlinkPath } -> ${ sourcePath } ` ) ;
633+ } catch ( e ) {
634+ console . error ( `Error creating ${ label } symlink:` , e . message ) ;
635+ // Fallback: copy the file if symlink fails
636+ copyFile ( sourcePath , symlinkPath ) ;
637+ console . log ( `Fallback: Copied file to ${ symlinkPath } ` ) ;
638+ }
639+ } catch ( e ) {
640+ console . error ( `Error creating ${ label } symlink:` , e . message ) ;
641+ }
642+ }
590643}
0 commit comments