@@ -18,19 +18,6 @@ mod linux {
1818 Other ,
1919 }
2020
21- /// Detected init system on Linux.
22- #[ derive( Debug , Clone , Copy , PartialEq , Eq ) ]
23- pub enum InitSystem {
24- /// systemd init system.
25- Systemd ,
26- /// OpenRC init system.
27- OpenRc ,
28- /// runit init system.
29- Runit ,
30- /// Other or unknown init system.
31- Other ,
32- }
33-
3421 /// Detect the current desktop environment.
3522 ///
3623 /// Checks the `XDG_CURRENT_DESKTOP` and `XDG_SESSION_DESKTOP` environment variables,
@@ -83,51 +70,6 @@ mod linux {
8370 DesktopEnvironment :: Other
8471 }
8572
86- /// Detect the current init system.
87- ///
88- /// Checks for systemd by looking for `/run/systemd/system` or `systemctl` command.
89- /// Checks for OpenRC by looking for `/run/openrc` or `openrc-status` command.
90- /// Checks for runit by looking for `/run/runit` or `runit` command.
91- ///
92- /// Returns `InitSystem::Other` if detection fails.
93- pub fn detect_init_system ( ) -> InitSystem {
94- // Check for systemd (most common).
95- // Check paths first (faster), then fall back to which command.
96- if std:: path:: Path :: new ( "/run/systemd/system" ) . exists ( )
97- || std:: path:: Path :: new ( "/usr/lib/systemd" ) . exists ( )
98- {
99- return InitSystem :: Systemd ;
100- }
101- // Check for systemctl command (more reliable detection).
102- if which:: which ( "systemctl" ) . is_ok ( ) {
103- return InitSystem :: Systemd ;
104- }
105-
106- // Check for OpenRC (Gentoo, Alpine, etc.).
107- if std:: path:: Path :: new ( "/run/openrc" ) . exists ( )
108- || std:: path:: Path :: new ( "/etc/init.d" ) . exists ( )
109- {
110- return InitSystem :: OpenRc ;
111- }
112- // Check for openrc-status command.
113- if which:: which ( "openrc-status" ) . is_ok ( ) {
114- return InitSystem :: OpenRc ;
115- }
116-
117- // Check for runit (Void Linux, etc.).
118- if std:: path:: Path :: new ( "/run/runit" ) . exists ( )
119- || std:: path:: Path :: new ( "/etc/runit" ) . exists ( )
120- {
121- return InitSystem :: Runit ;
122- }
123- // Check for runit command.
124- if which:: which ( "runit" ) . is_ok ( ) {
125- return InitSystem :: Runit ;
126- }
127-
128- InitSystem :: Other
129- }
130-
13173 /// Get the system settings command for a given desktop environment and pane.
13274 ///
13375 /// Returns a vector of command and arguments, or `None` if no command is available
0 commit comments