some scx impl

This commit is contained in:
Ward from fusion-voyager-3 2024-06-20 00:12:17 +03:00
parent 42d34c9c17
commit 05fd326f62
8 changed files with 71 additions and 8 deletions

10
data/scripts/change_scx.sh Executable file
View File

@ -0,0 +1,10 @@
#! /bin/bash
if [[ "$1" == "scx_disabled" ]]; then
systemctl stop scx & systemctl disable scx
else
set -e
sed -i 's/SCX_SCHEDULER=.*/SCX_SCHEDULER="$1"/' /etc/default/scx
systemctl enable --now scx
systemctl restart scx
fi

Binary file not shown.

0
data/scripts/get_version.sh Normal file → Executable file
View File

0
data/scripts/kernel-cachyos-init.sh Normal file → Executable file
View File

0
data/scripts/modify_package.sh Normal file → Executable file
View File

View File

@ -86,7 +86,7 @@ pub fn build_ui(app: &adw::Application) {
Some("content_page"), Some("content_page"),
); );
content_stack.add_named( content_stack.add_named(
&sched_ext::sched_ext_page(&content_stack), &sched_ext::sched_ext_page(&content_stack, &window),
Some("sched_ext_page"), Some("sched_ext_page"),
); );

View File

@ -463,7 +463,7 @@ fn get_cpu_feature_level() -> String {
.trim_end_matches("(supported, searched)") .trim_end_matches("(supported, searched)")
.trim() .trim()
.to_string(), .to_string(),
_ => "x86_64-v1".to_string(), _ => "x86-64-v1".to_string(),
}; };
result result
} }

View File

@ -4,10 +4,13 @@ use adw::prelude::*;
use glib::*; use glib::*;
use gtk::prelude::*; use gtk::prelude::*;
use gtk::*; use gtk::*;
use std::fs; use std::{fs, io};
use std::fs::*; use std::fs::*;
use std::process::Stdio;
use duct::cmd;
use gtk::AccessibleRole::Command;
pub fn sched_ext_page(content_stack: &gtk::Stack) -> gtk::Box { pub fn sched_ext_page(content_stack: &gtk::Stack, window: &adw::ApplicationWindow,) -> gtk::Box {
let main_box = gtk::Box::builder() let main_box = gtk::Box::builder()
.hexpand(true) .hexpand(true)
.vexpand(true) .vexpand(true)
@ -60,7 +63,12 @@ pub fn sched_ext_page(content_stack: &gtk::Stack) -> gtk::Box {
.subtitle("Select Sched-EXT Scheduler") .subtitle("Select Sched-EXT Scheduler")
.build(); .build();
scx_sched_expander_row.add_row(&scx_sched_expandable(&scx_sched_expander_row)); scx_sched_expander_row.add_row(&scx_sched_expandable(&scx_sched_expander_row,
&window,
&badge_box,
&kernel_badges_size_group,
&kernel_badges_size_group0,
&kernel_badges_size_group1,));
let scx_sched_expander_row_boxedlist = gtk::ListBox::builder() let scx_sched_expander_row_boxedlist = gtk::ListBox::builder()
.selection_mode(SelectionMode::None) .selection_mode(SelectionMode::None)
@ -147,7 +155,13 @@ fn create_current_sched_badge(
)); ));
} }
fn scx_sched_expandable(expander_row: &adw::ExpanderRow) -> gtk::ListBox { fn scx_sched_expandable(expander_row: &adw::ExpanderRow,
window: &adw::ApplicationWindow,
badge_box: &gtk::Box,
kernel_badges_size_group: &gtk::SizeGroup,
kernel_badges_size_group0: &gtk::SizeGroup,
kernel_badges_size_group1: &gtk::SizeGroup,
) -> gtk::ListBox {
let searchbar = gtk::SearchEntry::builder().search_delay(500).build(); let searchbar = gtk::SearchEntry::builder().search_delay(500).build();
searchbar.add_css_class("round-border-only-top"); searchbar.add_css_class("round-border-only-top");
@ -181,15 +195,38 @@ fn scx_sched_expandable(expander_row: &adw::ExpanderRow) -> gtk::ListBox {
.build(); .build();
let branch_row = adw::ActionRow::builder() let branch_row = adw::ActionRow::builder()
.activatable_widget(&sched_checkbutton) .activatable_widget(&sched_checkbutton)
.title(sched) .title(&sched)
.build(); .build();
branch_row.add_prefix(&sched_checkbutton); branch_row.add_prefix(&sched_checkbutton);
sched_checkbutton.set_group(Some(&null_checkbutton)); sched_checkbutton.set_group(Some(&null_checkbutton));
sched_container.append(&branch_row); sched_container.append(&branch_row);
let cmd_status_dialog = adw::MessageDialog::builder()
.transient_for(window)
.hide_on_close(true)
.build();
cmd_status_dialog.add_response(
"cmd_status_dialog_ok",
"Ok",
);
sched_checkbutton.connect_toggled( sched_checkbutton.connect_toggled(
clone!(@weak sched_checkbutton, @weak expander_row => move |_| { clone!(@weak sched_checkbutton, @weak expander_row, @weak badge_box, @strong get_running_kernel_info, @weak kernel_badges_size_group, @weak kernel_badges_size_group0, @weak kernel_badges_size_group1 => move |_| {
if sched_checkbutton.is_active() == true { if sched_checkbutton.is_active() == true {
expander_row.set_title(&branch_row.title()); expander_row.set_title(&branch_row.title());
match change_scx_scheduler(&sched, &badge_box,
&kernel_badges_size_group,
&kernel_badges_size_group0,
&kernel_badges_size_group1,) {
Ok(_) => {
cmd_status_dialog.set_heading(Some("Success!"));
cmd_status_dialog.set_body(format!("SCX has been set to: {}", &sched).as_str());
cmd_status_dialog.present()
}
Err(_) => {
cmd_status_dialog.set_heading(Some("Failed!"));
cmd_status_dialog.set_body(format!("SCX couldn't be has been set to: {}", &sched).as_str());
cmd_status_dialog.present()
}
};
} }
}), }),
); );
@ -241,3 +278,19 @@ fn get_current_scx_scheduler() -> String {
scx_sched scx_sched
} }
fn change_scx_scheduler(scx_sched: &str,
badge_box: &gtk::Box,
kernel_badges_size_group: &gtk::SizeGroup,
kernel_badges_size_group0: &gtk::SizeGroup,
kernel_badges_size_group1: &gtk::SizeGroup,) -> Result<(), io::Error> {
cmd!("pkexec", "bash", "-c", format!("/home/ward/RustroverProjects/fedora-kernel-manager/data/scripts/change_scx.sh {}", scx_sched)).run()?;
create_current_sched_badge(
&badge_box,
&get_running_kernel_info(),
&kernel_badges_size_group,
&kernel_badges_size_group0,
&kernel_badges_size_group1,
);
Ok(())
}