feat: swaync cpu frequency slider

This commit is contained in:
2025-09-26 08:57:30 +03:00
parent 9f7b47f8ea
commit 6f039f587b
3 changed files with 71 additions and 22 deletions

View File

@@ -2,13 +2,12 @@
CURRENT=$(sudo cpupower frequency-info | grep 'current policy: frequency should be within 400 MHz and' | awk '{printf "%.2f%s", $10, substr($11, 1, length($11)-1)}') CURRENT=$(sudo cpupower frequency-info | grep 'current policy: frequency should be within 400 MHz and' | awk '{printf "%.2f%s", $10, substr($11, 1, length($11)-1)}')
echo Current freq is $CURRENT
set_cmd() { set_cmd() {
sudo cpupower frequency-set --max $1MHz sudo cpupower frequency-set --max $1MHz
notify-send -t 800 "$1MHz CPU Power" notify-send -t 800 "$1MHz CPU Power"
} }
if [ -z "$1" ]; then
if [ $CURRENT = "400.00MHz" ]; then if [ $CURRENT = "400.00MHz" ]; then
set_cmd 600 set_cmd 600
exit 0 exit 0
@@ -33,6 +32,27 @@ if [ $CURRENT = "4.20GHz" ]; then
set_cmd 400 set_cmd 400
exit 0 exit 0
fi fi
else
if [ "$1" = "g" ]; then
case $CURRENT in
"400.00MHz") echo 1 ;;
"600.00MHz") echo 2 ;;
"1000.00MHz") echo 3 ;;
"2.00GHz") echo 4 ;;
"4.20GHz") echo 5 ;;
*) echo "Unknown frequency" ;;
esac
exit 0
fi
case $1 in
1) set_cmd 400 ;;
2) set_cmd 600 ;;
3) set_cmd 1000 ;;
4) set_cmd 2000 ;;
5) set_cmd 4200 ;;
esac
exit 0
fi
notify-send CPU-Power Error: value is $CURRENT notify-send CPU-Power Error: value is $CURRENT
exit 1 exit 1

View File

@@ -47,6 +47,22 @@ vim.keymap.set("n", "<space>gb", dap.run_to_cursor, { desc = "Dap Run to cursor"
local function toggle_terminal() local function toggle_terminal()
require("nvchad.term").toggle { pos = "sp", id = "htoggleTerm" } require("nvchad.term").toggle { pos = "sp", id = "htoggleTerm" }
end end
local function toggle_git_add()
local filepath = vim.fn.expand("%:p") -- Get the full path of the current file
local handle = io.popen("git ls-files --cached --error-unmatch " .. filepath .. " 2>/dev/null") -- Check if the file is staged
local result = handle:read("*a")
handle:close()
if result ~= "" then
os.execute("git reset " .. filepath) -- Unstage the file if it's already staged
print("Unstaged: " .. filepath)
else
os.execute("git add " .. filepath) -- Stage the file if it's not staged
print("Staged: " .. filepath)
end
end
map({ "n", "t" }, "<A-b>", toggle_terminal, { desc = "terminal toggleable horizontal term" }) map({ "n", "t" }, "<A-b>", toggle_terminal, { desc = "terminal toggleable horizontal term" })
map({ "n", "t" }, "<C-`>", toggle_terminal, { desc = "terminal toggleable horizontal term" }) map({ "n", "t" }, "<C-`>", toggle_terminal, { desc = "terminal toggleable horizontal term" })
@@ -86,6 +102,9 @@ vim.keymap.set("n", "<leader>ft", '<cmd>TodoTelescope<cr>', { desc = "Telescope
-- nvimtree refresh -- nvimtree refresh
vim.keymap.set("n", "<leader>tr", '<cmd>NvimTreeRefresh<cr>', { desc = "Nvimtree Refresh" }) vim.keymap.set("n", "<leader>tr", '<cmd>NvimTreeRefresh<cr>', { desc = "Nvimtree Refresh" })
-- toggle git add current file
vim.keymap.set("n", "<leader>ga", toggle_git_add, { desc = "Toggle git add for current file" })
-- nvimtree open file without focusing -- nvimtree open file without focusing
vim.keymap.set("n", "T", vim.keymap.set("n", "T",
function(node) function(node)

View File

@@ -54,7 +54,8 @@
"menubar", "menubar",
"buttons-grid", "buttons-grid",
"volume", "volume",
"slider", "slider#brightness",
"slider#cpu",
"inhibitors", "inhibitors",
"title", "title",
"notifications", "notifications",
@@ -77,7 +78,7 @@
"show-per-app-icon": true, "show-per-app-icon": true,
"show-per-app-label": true "show-per-app-label": true
}, },
"slider": { "slider#brightness": {
"label": " ", "label": " ",
"cmd_setter": "brightnessctl s $value", "cmd_setter": "brightnessctl s $value",
"cmd_getter": "brightnessctl g", "cmd_getter": "brightnessctl g",
@@ -86,6 +87,15 @@
"max": 120000, "max": 120000,
"max_limit": 120000 "max_limit": 120000
}, },
"slider#cpu": {
"label": " ",
"cmd_setter": "exec ~/.config/hypr/scripts/cpufreq.sh $value",
"cmd_getter": "exec ~/.config/hypr/scripts/cpufreq.sh g",
"min": 1,
"min_limit": 1,
"max": 5,
"max_limit": 5
},
"dnd": { "dnd": {
"text": "Don't bother" "text": "Don't bother"
}, },