Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions archinstall/default_profiles/desktop.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from typing import TYPE_CHECKING, override

from archinstall.default_profiles.profile import GreeterType, Profile, ProfileType, SelectResult
from archinstall.lib.hardware import SysInfo
from archinstall.lib.output import info
from archinstall.lib.profile.profiles_handler import profile_handler
from archinstall.tui.curses_menu import SelectMenu
Expand Down Expand Up @@ -99,6 +100,9 @@ def install(self, install_session: 'Installer') -> None:
# Install common packages for all desktop environments
install_session.add_additional_packages(self.packages)

if SysInfo.has_battery():
install_session.add_additional_packages('power-profiles-daemon')

for profile in self.current_selection:
info(f'Installing profile {profile.name}...')

Expand Down
13 changes: 13 additions & 0 deletions archinstall/lib/hardware.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,19 @@ def loaded_modules(self) -> list[str]:


class SysInfo:
@staticmethod
def has_battery():
for device in os.listdir('/sys/class/power_supply/'):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can be simplified with

Path('/sys/class/power_supply/').glob('*/type')

device_type_path = os.path.join('/sys/class/power_supply/', device, 'type')
try:
with open(device_type_path) as f:
if f.read().strip() == 'Battery':
return True
except OSError:
continue

return False

@staticmethod
def has_wifi() -> bool:
ifaces = list(list_interfaces().values())
Expand Down