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,36 +2,56 @@
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() {
sudo cpupower frequency-set --max $1MHz
notify-send -t 800 "$1MHz CPU Power"
}
if [ $CURRENT = "400.00MHz" ]; then
if [ -z "$1" ]; then
if [ $CURRENT = "400.00MHz" ]; then
set_cmd 600
exit 0
fi
fi
if [ $CURRENT = "600.00MHz" ]; then
if [ $CURRENT = "600.00MHz" ]; then
set_cmd 1000
exit 0
fi
fi
if [ $CURRENT = "1000.00MHz" ]; then
if [ $CURRENT = "1000.00MHz" ]; then
set_cmd 2000
exit 0
fi
fi
if [ $CURRENT = "2.00GHz" ]; then
if [ $CURRENT = "2.00GHz" ]; then
set_cmd 4200
exit 0
fi
fi
if [ $CURRENT = "4.20GHz" ]; then
if [ $CURRENT = "4.20GHz" ]; then
set_cmd 400
exit 0
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

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()
require("nvchad.term").toggle { pos = "sp", id = "htoggleTerm" }
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" }, "<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
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
vim.keymap.set("n", "T",
function(node)

View File

@@ -54,7 +54,8 @@
"menubar",
"buttons-grid",
"volume",
"slider",
"slider#brightness",
"slider#cpu",
"inhibitors",
"title",
"notifications",
@@ -77,7 +78,7 @@
"show-per-app-icon": true,
"show-per-app-label": true
},
"slider": {
"slider#brightness": {
"label": " ",
"cmd_setter": "brightnessctl s $value",
"cmd_getter": "brightnessctl g",
@@ -86,6 +87,15 @@
"max": 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": {
"text": "Don't bother"
},