@@ -205,29 +205,39 @@ pub struct Defaults {
205205 pub autostart : bool ,
206206 pub autostart_minimized : bool ,
207207 pub port : u16 ,
208- pub discovery_path : PathBuf ,
208+ pub discovery_paths : Vec < PathBuf > ,
209209}
210210
211211impl Default for Defaults {
212212 fn default ( ) -> Self {
213- let discovery_path = if cfg ! ( target_os = "linux" ) {
214- UserDirs :: new ( )
215- . map ( |dirs| dirs. home_dir ( ) . join ( "aw-modules" ) )
216- . unwrap_or_default ( )
213+ let mut discovery_paths = Vec :: new ( ) ;
214+
215+ if cfg ! ( target_os = "linux" ) {
216+ if let Some ( dirs) = UserDirs :: new ( ) {
217+ discovery_paths. push ( dirs. home_dir ( ) . join ( "aw-modules" ) ) ;
218+ }
217219 } else if cfg ! ( windows) {
218- let username = std:: env:: var ( "USERNAME" ) . unwrap_or_default ( ) ;
219- PathBuf :: from ( format ! ( r"C:\Users\{}\aw-modules" , username) )
220+ if let Ok ( username) = std:: env:: var ( "USERNAME" ) {
221+ discovery_paths. push ( PathBuf :: from ( format ! ( r"C:\Users\{}\aw-modules" , username) ) ) ;
222+ discovery_paths. push ( PathBuf :: from ( format ! (
223+ r"C:\Users\{}\AppData\Local\Programs\ActivityWatch\" ,
224+ username
225+ ) ) ) ;
226+ }
220227 } else if cfg ! ( target_os = "macos" ) {
221- PathBuf :: from ( "/Applications/ActivityWatch.app/Contents/MacOS" )
222- } else {
223- PathBuf :: new ( )
224- } ;
228+ if let Some ( dirs) = UserDirs :: new ( ) {
229+ discovery_paths. push ( dirs. home_dir ( ) . join ( "aw-modules" ) ) ;
230+ }
231+ discovery_paths. push ( PathBuf :: from (
232+ "/Applications/ActivityWatch.app/Contents/MacOS" ,
233+ ) ) ;
234+ }
225235
226236 Defaults {
227237 autostart : true ,
228238 autostart_minimized : true ,
229- port : 5699 , // TODO: update before going stable
230- discovery_path ,
239+ port : 5699 ,
240+ discovery_paths ,
231241 }
232242 }
233243}
0 commit comments