File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 33use std:: {
44 collections:: HashMap ,
55 path:: { Path , PathBuf } ,
6+ sync:: LazyLock ,
67 vec:: Vec ,
78} ;
89
910use icon;
1011use walkdir:: WalkDir ;
1112
1213use super :: { App , Icon } ;
14+ use crate :: constants;
1315use crate :: serworse;
1416
1517#[ derive( Default ) ]
1618pub struct LinuxAppSearcher {
1719 icon_searcher : icon:: Icons ,
1820}
1921
22+ static ICON_THEME_NAME : LazyLock < String > = LazyLock :: new ( || {
23+ let get_gtk3 = || -> Option < String > {
24+ Some (
25+ serworse:: parse_ini_format (
26+ & std:: fs:: read_to_string (
27+ constants:: HOME_DIR . clone ( ) + "/.config/gtk-3.0/settings.ini" ,
28+ )
29+ . ok ( ) ?,
30+ )
31+ . ok ( ) ?
32+ . get ( "Settings" ) ?
33+ . get ( "gtk-icon-theme-name" ) ?
34+ . to_string ( ) ,
35+ )
36+ } ;
37+
38+ let get_gtk2 = || -> Option < String > {
39+ Some (
40+ serworse:: parse_xsv :: < String > (
41+ & std:: fs:: read_to_string ( constants:: HOME_DIR . clone ( ) + "/.gtkrc-2.0" ) . ok ( ) ?,
42+ '=' ,
43+ )
44+ . ok ( ) ?
45+ . get ( "gtk-icon-theme-name" )
46+ . expect ( "asdf" )
47+ . to_string ( ) ,
48+ )
49+ } ;
50+
51+ let theme = get_gtk3 ( )
52+ . or_else ( get_gtk2)
53+ . unwrap_or ( "Adwaita" . to_string ( ) ) ;
54+ log:: warn!( "Icon theme picked was: {theme}" ) ;
55+ theme
56+ } ) ;
57+
2058impl super :: OSAppSearcher for LinuxAppSearcher {
2159 fn get_apps ( & self ) -> Vec < App > {
2260 load_desktop_entries ( )
@@ -32,7 +70,7 @@ impl super::OSAppSearcher for LinuxAppSearcher {
3270 }
3371
3472 self . icon_searcher
35- . find_icon ( s. as_str ( ) , 64 , 1 , "Adwaita" ) // TODO. Dont hardcode theme
73+ . find_icon ( s. as_str ( ) , 64 , 1 , & ICON_THEME_NAME )
3674 . map ( |i| i. path ( ) . to_path_buf ( ) )
3775 }
3876
You can’t perform that action at this time.
0 commit comments