rofi brightness menu

This commit is contained in:
Noah Masur 2023-04-02 15:52:45 -04:00
parent d6611ca7a2
commit 8283480fd1
10 changed files with 74 additions and 17 deletions

View File

@ -21,6 +21,10 @@
type = lib.types.str; type = lib.types.str;
description = "Command to use for switching audio sink"; description = "Command to use for switching audio sink";
}; };
brightnessCommand = lib.mkOption {
type = lib.types.str;
description = "Command to use for adjusting brightness";
};
toggleBarCommand = lib.mkOption { toggleBarCommand = lib.mkOption {
type = lib.types.str; type = lib.types.str;
description = "Command to hide and show the status bar."; description = "Command to hide and show the status bar.";

View File

@ -121,6 +121,8 @@ in {
"Mod1+Tab" = "exec --no-startup-id ${config.altTabCommand}"; "Mod1+Tab" = "exec --no-startup-id ${config.altTabCommand}";
"${modifier}+Shift+period" = "${modifier}+Shift+period" =
"exec --no-startup-id ${config.powerCommand}"; "exec --no-startup-id ${config.powerCommand}";
"${modifier}+Shift+m" =
"exec --no-startup-id ${config.brightnessCommand}";
"${modifier}+Shift+c" = "reload"; "${modifier}+Shift+c" = "reload";
"${modifier}+Shift+r" = "restart"; "${modifier}+Shift+r" = "restart";
"${modifier}+Shift+q" = '' "${modifier}+Shift+q" = ''

View File

@ -6,7 +6,7 @@ let
in { in {
imports = [ ./rofi/power.nix ]; imports = [ ./rofi/power.nix ./rofi/brightness.nix ];
config = lib.mkIf (pkgs.stdenv.isLinux && config.services.xserver.enable) { config = lib.mkIf (pkgs.stdenv.isLinux && config.services.xserver.enable) {

View File

@ -0,0 +1,49 @@
{ config, pkgs, ... }:
let
rofi = config.home-manager.users.${config.user}.programs.rofi.finalPackage;
in {
# Adapted from:
# A rofi powered menu to execute brightness choices.
config.brightnessCommand = builtins.toString
(pkgs.writeShellScript "brightness" ''
dimmer=""
medium=""
brighter=""
chosen=$(printf '%s;%s;%s\n' \
"$dimmer" \
"$medium" \
"$brighter" \
| ${rofi}/bin/rofi \
-theme-str '@import "brightness.rasi"' \
-hover-select \
-me-select-entry ''' \
-me-accept-entry MousePrimary \
-dmenu \
-sep ';' \
-selected-row 1)
case "$chosen" in
"$dimmer")
${pkgs.ddcutil}/bin/ddcutil --display 1 setvcp 10 25; ${pkgs.ddcutil}/bin/ddcutil --display 2 setvcp 10 25
;;
"$medium")
${pkgs.ddcutil}/bin/ddcutil --display 1 setvcp 10 75; ${pkgs.ddcutil}/bin/ddcutil --display 2 setvcp 10 75
;;
"$brighter")
${pkgs.ddcutil}/bin/ddcutil --display 1 setvcp 10 100; ${pkgs.ddcutil}/bin/ddcutil --display 2 setvcp 10 100
;;
*) exit 1 ;;
esac
'');
}

View File

@ -1,10 +0,0 @@
#!/usr/bin/env bash
# THEME="$HOME/.config/rofi/config.rasi"
ICON_UP=""
ICON_DOWN=""
ICON_OPT=""
options="$ICON_UP\n$ICON_OPT\n$ICON_DOWN"
chosen="$(echo -e "$options" | rofi -theme-str 'listview { layout:horizontal; }' -dmenu)"
echo "$chosen"

View File

@ -23,7 +23,10 @@ in {
"$suspend" \ "$suspend" \
"$log_out" \ "$log_out" \
| ${rofi}/bin/rofi \ | ${rofi}/bin/rofi \
-theme-str '@import "power.rasi"' \ -theme-str '@import "power.rasi"' \
-hover-select \
-me-select-entry ''' \
-me-accept-entry MousePrimary \
-dmenu \ -dmenu \
-sep ';' \ -sep ';' \
-selected-row 2) -selected-row 2)

View File

@ -31,6 +31,9 @@ done
chosen=$(printf '%s;%s\n' "$yes" "$no" | chosen=$(printf '%s;%s\n' "$yes" "$no" |
rofi -theme-str '@import "prompt.rasi"' \ rofi -theme-str '@import "prompt.rasi"' \
-hover-select \
-me-select-entry '' \
-me-accept-entry MousePrimary \
-p "$query" \ -p "$query" \
-dmenu \ -dmenu \
-sep ';' \ -sep ';' \

View File

@ -0,0 +1,6 @@
@import "common.rasi"
#window {
width: 605px;
height: 230px;
}

View File

@ -33,11 +33,6 @@
vpn-textbox-prompt-colon-padding: @network-textbox-prompt-colon-padding; vpn-textbox-prompt-colon-padding: @network-textbox-prompt-colon-padding;
} }
#window {
width: 980px;
height: 230px;
}
/** /**
* Settings used in every rofi option menu: * Settings used in every rofi option menu:
*/ */

View File

@ -1 +1,6 @@
@import "common.rasi" @import "common.rasi"
#window {
width: 980px;
height: 230px;
}