diff options
| author | venomade <venomade@venomade.com> | 2026-02-11 11:42:58 +0000 |
|---|---|---|
| committer | venomade <venomade@venomade.com> | 2026-02-11 11:42:58 +0000 |
| commit | 0bd150185551b6d8835d022c15a5f6e832d51113 (patch) | |
| tree | 10bf3f3443df49a44eb47b328b73b7e76b0a4924 /.local/bin/rofi-ppd | |
| parent | 8d688d1107c46b6dfdcaf02fa5c9c4c8a4640e65 (diff) | |
Asahi
Soft reset of dotfiles specific to Asahi, Sway and Neovim.
Diffstat (limited to '.local/bin/rofi-ppd')
| -rwxr-xr-x | .local/bin/rofi-ppd | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/.local/bin/rofi-ppd b/.local/bin/rofi-ppd new file mode 100755 index 0000000..5a4f13b --- /dev/null +++ b/.local/bin/rofi-ppd @@ -0,0 +1,48 @@ +#!/usr/bin/env lua + +local function trim(s) + return s:gsub("^%s+", ""):gsub("%s+$", "") +end + +local function rofi(prompt, lines) + local cmd = string.format( + 'printf "%s" | rofi -dmenu -i -p "%s"', + table.concat(lines, "\n"), + prompt + ) + local handle = io.popen(cmd) + local selection = handle:read("*a") + handle:close() + selection = trim(selection or "") + if selection == "" then return nil end + return selection +end + +local modes = {} + +local handle = io.popen('powerprofilesctl list') +local profile_list = handle:read("*a") +handle:close() + +local handle = io.popen('powerprofilesctl get') +local current_profile = trim(handle:read("*a") or "") +handle:close() + +for line in profile_list:gmatch("[^\r\n]+") do + line = trim(line) + local mode = line:match("^%*?%s*([%w%-_]+)%s*:$") + if mode then + if mode == current_profile then + table.insert(modes, "* " .. mode) + else + table.insert(modes, " " .. mode) + end + end +end + +local selected_profile = rofi('', modes) +if not selected_profile then os.exit() end + +selected_profile = selected_profile:gsub("^%*%s*", ""):gsub("^%s+", "") + +io.popen('powerprofilesctl set ' .. selected_profile) |
