Skip to content

Commit

Permalink
chwd: Some cleanups (#134)
Browse files Browse the repository at this point in the history
* chwd: Remove nonfree heuristics

* chwd: Remove USB options

We're not handling it properly right now

* chwd: Remove is_nvidia_card option

* chwd: Change argument from vector to optional string

* chwd: Remove pci option

Right now we don't handle any devices other than PCI by default, so it's
useless.

* chwd: Require listing options to be specified for detailed output

* chwd: Remove type field from Device

* chwd: All profiles are now for PCI
  • Loading branch information
ventureoo authored Aug 21, 2024
1 parent cfde726 commit 964cd61
Show file tree
Hide file tree
Showing 18 changed files with 64 additions and 210 deletions.
5 changes: 2 additions & 3 deletions i18n/cs/chwd.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
name-header = Jméno
desc-header = Popis
priority-header = Priorita
nonfree-header = Placené
classids-header = ID Třídy
vendorids-header = ID Prodejce
Expand All @@ -19,12 +18,12 @@ pass-profile-no-match-install = uvedený profil se neshoduje s nainstalovaným p
available = DOSTUPNÉ
installed = NAINSTALOVÁNO
device = Zařízení
no-profile-device = nebyly nalezeny žádné profily pro zařízení '{$device_type}'!
no-profile-device = nebyly nalezeny žádné profily pro zařízení PCI!
# Výstup v konzoly
invalid-profile = profil '{$invalid_profile}' je neplatný!
all-pci-profiles = Všechny PCI profily:
installed-pci-profiles = Instalované PCI profily:
pci-profiles-not-found = Žádné PCI profily nebyly nalezeny!
no-installed-pci-profiles = Žádné PCI profili nejsou nainstalovány!
no-installed-profile-device = žádný nainstalovaný profil pro zařízení '{$device_type}' nebyl nalezen !
no-installed-profile-device = žádný nainstalovaný profil pro zařízení PCI nebyl nalezen !
5 changes: 2 additions & 3 deletions i18n/en/chwd.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
name-header = Name
desc-header = Desc
priority-header = Priority
nonfree-header = NonFree
classids-header = ClassIDS
vendorids-header = VendorIDS
Expand All @@ -19,12 +18,12 @@ pass-profile-no-match-install = passed profile does not match with installed pro
available = AVAILABLE
installed = INSTALLED
device = Device
no-profile-device = no profiles for '{$device_type}' devices found!
no-profile-device = no profiles for PCI devices found!
# console writer
invalid-profile = profile '{$invalid_profile}' is invalid!
all-pci-profiles = All PCI profiles:
installed-pci-profiles = Installed PCI profiles:
pci-profiles-not-found = No PCI profiles found!
no-installed-pci-profiles = No installed PCI profiles!
no-installed-profile-device = no installed profile for '{$device_type}' devices found!
no-installed-profile-device = no installed profile for PCI devices found!
5 changes: 2 additions & 3 deletions i18n/ru/chwd.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
name-header = Имя
desc-header = Описание
priority-header = Приоритет
nonfree-header = Несвободный
classids-header = IDS класса
vendorids-header = IDS вендора
Expand All @@ -19,12 +18,12 @@ pass-profile-no-match-install = переданный профиль не сов
available = ДОСТУПНО
installed = УСТАНОВЛЕНО
device = Устройство
no-profile-device = профили для устройств '{$device_type}' не найдены!
no-profile-device = профили для устройств PCI не найдены!
# console writer
invalid-profile = профиль '{$invalid_profile}' недействительный!
all-pci-profiles = Все PCI профили:
installed-pci-profiles = Установленные PCI профили:
pci-profiles-not-found = PCI профили не найдены!
no-installed-pci-profiles = Нет установленных PCI профилей!
no-installed-profile-device = не найдено ни одного установленного профиля для устройств '{$device_type}'!
no-installed-profile-device = не найдено ни одного установленного профиля для устройств PCI!
5 changes: 2 additions & 3 deletions i18n/sk/chwd.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
name-header = Meno
desc-header = Popis
priority-header = Priorita
nonfree-header = Platené
classids-header = ID Triedy
vendorids-header = ID Predajcu
Expand All @@ -19,12 +18,12 @@ pass-profile-no-match-install = uvedený profil sa nezhoduje s nainštalovaným
available = DOSTUPNÉ
installed = NAINŠTALOVANÉ
device = Zariadenie
no-profile-device = neboli nájdené žiadne profily pre zariadenia '{$device_type}'!
no-profile-device = neboli nájdené žiadne profily pre zariadenia PCI!
# Výstup v konzoly
invalid-profile = profil '{$invalid_profile}' je neplatný!
all-pci-profiles = Všetky PCI profily:
installed-pci-profiles = Inštalované PCI profily:
pci-profiles-not-found = Žiadne PCI profily neboli nájdené!
no-installed-pci-profiles = Žiadne PCI profily nie sú nainštalované!
no-installed-profile-device = žiadny nainštalovaný profil pre zariadenie '{$device_type}' nebol nájdený !
no-installed-profile-device = žiadny nainštalovaný profil pre zariadenie PCI nebol nájdený !
2 changes: 0 additions & 2 deletions profiles/pci/ai_sdk/profiles.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

[nvidia-ai-sdk]
desc = 'NVIDIA AI SDK and related tools'
nonfree = true
ai_sdk = true
#class_ids = "*"
class_ids = "0300 0302"
Expand All @@ -21,7 +20,6 @@ device_name_pattern = '(AD|GV|TU|GA|GH|GM|GP)\w+'

[rocm-ai-sdk]
desc = 'AMD AI SDK and related tools'
nonfree = true
ai_sdk = true
class_ids = "*"
vendor_ids = "1002"
Expand Down
9 changes: 0 additions & 9 deletions profiles/pci/graphic_drivers/profiles.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@

[nvidia-open-dkms]
desc = 'Open source NVIDIA drivers for Linux (Latest)'
nonfree = true
class_ids = "0300 0302 0380"
vendor_ids = "10de"
priority = 10
Expand Down Expand Up @@ -80,7 +79,6 @@ post_remove = """

[nvidia-dkms]
desc = 'Closed source NVIDIA drivers for Linux (Latest)'
nonfree = true
class_ids = "0300 0302 0380"
vendor_ids = "10de"
priority = 12
Expand Down Expand Up @@ -142,7 +140,6 @@ post_remove = """
[nvidia-dkms-470xx]
desc = 'Closed source NVIDIA drivers for Linux (470xx branch, only for Kepler GPUs)'
priority = 14
nonfree = true
class_ids = "0300 0380"
vendor_ids = "10de"
packages = 'nvidia-470xx-dkms nvidia-470xx-utils nvidia-470xx-settings opencl-nvidia-470xx vulkan-icd-loader lib32-nvidia-470xx-utils lib32-opencl-nvidia-470xx lib32-vulkan-icd-loader libva-nvidia-driver'
Expand All @@ -168,15 +165,13 @@ post_install = """
[nvidia-dkms-390xx]
desc = 'Closed source NVIDIA drivers for Linux (390xx branch, only for Fermi GPUs)'
priority = 16
nonfree = true
vendor_ids = "10de"
class_ids = "0300 0302 0380"
packages = 'nvidia-390xx-dkms nvidia-390xx-utils nvidia-390xx-settings opencl-nvidia-390xx nvidia-390xx-utils nvidia-390xx-settings opencl-nvidia-390xx lib32-nvidia-390xx-utils lib32-opencl-nvidia-390xx'
device_name_pattern = '(GF)\w+'

[nouveau]
desc = "Open Nouveau driver for NVIDIA graphics cards (Only for old GPUs)"
nonfree = false
class_ids = "0300 0302"
vendor_ids = "10de"
priority = 0
Expand All @@ -189,7 +184,6 @@ fi

[intel]
desc = "Mesa open source driver for Intel"
nonfree = false
class_ids = "0300 0302"
vendor_ids = "8086"
device_ids = "*"
Expand All @@ -203,7 +197,6 @@ fi

[amd]
desc = "Mesa open source driver for AMD"
nonfree = false
class_ids = "0300 0302"
vendor_ids = "1002"
device_ids = "*"
Expand All @@ -217,7 +210,6 @@ fi

[fallback]
desc = 'Fallback profile'
nonfree = false
class_ids = "0300 0380 0302"
vendor_ids = "1002 8086 10de"
device_ids = "*"
Expand All @@ -226,7 +218,6 @@ packages = 'mesa lib32-mesa vulkan-swrast xf86-video-vesa'

[virtualmachine]
desc = 'X.org vmware video driver and open-vm-tools/virtualbox tools'
nonfree = false
class_ids = "0300"
# Virtualbox version 6.0 uses VMSVGA on Linux guests by default, which has VMWare's VENDORID.
# VENDOR VMWare=80ee Virtualbox=15AD Redhat(QXL)=1af4 Redhat(VirtIO)=1b36 cirrus=1013
Expand Down
2 changes: 0 additions & 2 deletions profiles/pci/handhelds/profiles.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

[steam-deck]
desc = 'Valve Steam Deck'
nonfree = false
class_ids = "0300"
vendor_ids = "1002"
device_ids = "1435 163f"
Expand Down Expand Up @@ -54,7 +53,6 @@ post_remove = """

[phoenix]
desc = 'ASUS ROG Ally and Lenovo Legion Go'
nonfree = false
class_ids = "0300"
vendor_ids = "1002"
device_ids = "15bf"
Expand Down
1 change: 0 additions & 1 deletion profiles/pci/network_drivers/profiles.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
[broadcom-wl]
desc = 'Broadcom 802.11 Linux STA wireless driver'
nonfree = false
class_ids = "0200 0280 0282"
vendor_ids = "14E4 14A4"
device_ids = "4311 4312 4315 4727 4328 4329 432A 432B 432C 432D 0576 4353 4357 4358 4359 4365 4331 43B1 43A0 4360"
Expand Down
29 changes: 11 additions & 18 deletions src/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,50 +16,43 @@
// with this program; if not, write to the Free Software Foundation, Inc.,
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.

use clap::builder::ArgPredicate;
use clap::Parser;

#[derive(Parser, Debug)]
#[command(author, version, about, long_about = None)]
pub struct Args {
/// Show PCI
#[arg(long = "pci")]
pub show_pci: bool,

/// Install profile
#[arg(short, long, number_of_values = 2, value_names = &["usb/pci", "profile"], conflicts_with("remove"))]
pub install: Option<Vec<String>>,
#[arg(short, long, value_name = "profile", conflicts_with("remove"))]
pub install: Option<String>,

/// Remove profile
#[arg(short, long, number_of_values = 2, value_names = &["usb/pci", "profile"], conflicts_with("install"))]
pub remove: Option<Vec<String>>,
#[arg(short, long, value_name = "profile", conflicts_with("install"))]
pub remove: Option<String>,

/// Show detailed info for listings
#[arg(short, long)]
#[arg(short, long, requires_if(ArgPredicate::IsPresent, "listings"))]
pub detail: bool,

/// Force reinstall
#[arg(short, long)]
pub force: bool,

/// List installed kernels
#[arg(long)]
#[arg(long, group = "listings")]
pub list_installed: bool,

/// List available profiles for all devices
#[arg(long = "list")]
#[arg(long = "list", group = "listings")]
pub list_available: bool,

/// List all profiles
#[arg(long)]
#[arg(long, group = "listings")]
pub list_all: bool,

/// Autoconfigure
#[arg(short, long, number_of_values = 3, value_names = &["usb/pci", "free/nonfree", "classid"], conflicts_with_all(["install", "remove"]))]
pub autoconfigure: Option<Vec<String>>,

/// Print if nvidia card found
#[arg(long = "is_nvidia_card")]
pub is_nvidia_card: bool,
#[arg(short, long, value_name = "classid", conflicts_with_all(["install", "remove"]))]
pub autoconfigure: Option<String>,

/// Toggle AI SDK profiles
#[arg(long = "ai_sdk")]
Expand Down
30 changes: 15 additions & 15 deletions src/console_writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,32 +31,32 @@ pub fn handle_arguments_listing(data: &Data, args: &crate::args::Args) {
}

// List all profiles
if args.list_all && args.show_pci {
let all_pci_profiles = &data.all_pci_profiles;
if !all_pci_profiles.is_empty() {
list_profiles(all_pci_profiles, &fl!("all-pci-profiles"));
if args.list_all {
let all_profiles = &data.all_profiles;
if !all_profiles.is_empty() {
list_profiles(all_profiles, &fl!("all-pci-profiles"));
} else {
print_warning(&fl!("pci-profiles-not-found"));
}
}

// List installed profiles
if args.list_installed && args.show_pci {
let installed_pci_profiles = &data.installed_pci_profiles;
if args.list_installed {
let installed_profiles = &data.installed_profiles;
if args.detail {
print_installed_profiles("PCI", installed_pci_profiles);
} else if !installed_pci_profiles.is_empty() {
list_profiles(installed_pci_profiles, &fl!("installed-pci-profiles"));
print_installed_profiles(installed_profiles);
} else if !installed_profiles.is_empty() {
list_profiles(installed_profiles, &fl!("installed-pci-profiles"));
} else {
print_warning(&fl!("no-installed-pci-profiles"));
}
}

// List available profiles
if args.list_available && args.show_pci {
if args.list_available {
let pci_devices = &data.pci_devices;
if args.detail {
crate::device::print_available_profiles_in_detail("PCI", pci_devices);
crate::device::print_available_profiles_in_detail(pci_devices);
} else {
for pci_device in pci_devices.iter() {
let available_profiles = &pci_device.get_available_profiles();
Expand Down Expand Up @@ -90,18 +90,18 @@ pub fn list_profiles(profiles: &[Profile], header_msg: &str) {
.load_preset(UTF8_FULL)
.apply_modifier(UTF8_ROUND_CORNERS)
.set_content_arrangement(ContentArrangement::Dynamic)
.set_header(vec![&fl!("name-header"), &fl!("nonfree-header")]);
.set_header(vec![&fl!("name-header"), &fl!("priority-header")]);

for profile in profiles.iter() {
table.add_row(vec![&profile.name, &profile.is_nonfree.to_string()]);
table.add_row(vec![&profile.name, &profile.priority.to_string()]);
}

println!("{table}\n");
}

pub fn print_installed_profiles(device_type: &str, installed_profiles: &[Profile]) {
pub fn print_installed_profiles(installed_profiles: &[Profile]) {
if installed_profiles.is_empty() {
print_warning(&fl!("no-installed-profile-device", device_type = device_type));
print_warning(&fl!("no-installed-profile-device"));
return;
}

Expand Down
Loading

0 comments on commit 964cd61

Please sign in to comment.