@@ -7,6 +7,20 @@ import GLib from 'gi://GLib';
77import Gio from 'gi://Gio' ;
88import Shell from 'gi://Shell' ;
99
10+ import Gi from 'gi' ;
11+
12+ function try_require ( namespace , version = undefined ) {
13+ try {
14+ return Gi . require ( namespace , version ) ;
15+ } catch ( ex ) {
16+ logError ( ex ) ;
17+ return null ;
18+ }
19+ }
20+
21+ const GioUnix = GLib . check_version ( 2 , 79 , 2 ) === null ? try_require ( 'GioUnix' ) : null ;
22+ const DesktopAppInfo = GioUnix ?. DesktopAppInfo ?? Gio . DesktopAppInfo ;
23+
1024class File {
1125 constructor ( source_url , target_file , fallback_files = [ ] ) {
1226 const [ source_file ] = GLib . filename_from_uri (
@@ -26,21 +40,24 @@ class File {
2640 get_existing_content ( ) {
2741 for ( const existing_file of [ this . target_file , ...this . fallback_files ] ) {
2842 try {
29- return Shell . get_file_contents_utf8_sync ( existing_file ) ;
43+ return {
44+ filename : existing_file ,
45+ content : Shell . get_file_contents_utf8_sync ( existing_file ) ,
46+ } ;
3047 } catch ( ex ) {
3148 if ( ! ex . matches ( GLib . file_error_quark ( ) , GLib . FileError . NOENT ) )
3249 logError ( ex , `Can't read ${ JSON . stringify ( existing_file ) } ` ) ;
3350 }
3451 }
3552
36- return null ;
53+ return { filename : this . target_file , content : null } ;
3754 }
3855
3956 install ( ) {
40- const existing_content = this . get_existing_content ( ) ;
57+ const { filename , content } = this . get_existing_content ( ) ;
4158
42- if ( this . content === existing_content )
43- return false ;
59+ if ( this . content === content )
60+ return { filename , changed : false } ;
4461
4562 GLib . mkdir_with_parents (
4663 GLib . path_get_dirname ( this . target_file ) ,
@@ -56,7 +73,7 @@ class File {
5673 0o600
5774 ) ;
5875
59- return true ;
76+ return { filename : this . target_file , changed : true } ;
6077 }
6178
6279 uninstall ( ) {
@@ -109,9 +126,11 @@ export class Installer {
109126 }
110127
111128 install ( ) {
112- this . desktop_entry . install ( ) ;
129+ const dbus_service = this . dbus_service . install ( ) ;
130+ const desktop_entry = this . desktop_entry . install ( ) ;
131+ const app_info = DesktopAppInfo . new_from_filename ( desktop_entry . filename ) ;
113132
114- if ( this . dbus_service . install ( ) ) {
133+ if ( dbus_service . changed ) {
115134 Gio . DBus . session . call (
116135 'org.freedesktop.DBus' ,
117136 '/org/freedesktop/DBus' ,
@@ -125,6 +144,8 @@ export class Installer {
125144 null
126145 ) ;
127146 }
147+
148+ return app_info ;
128149 }
129150
130151 uninstall ( ) {
0 commit comments