redid volume & some refactoring
This commit is contained in:
parent
18a1ff2f2e
commit
b0c590080c
4 changed files with 120 additions and 63 deletions
16
sway/chbright.sh
Executable file
16
sway/chbright.sh
Executable file
|
|
@ -0,0 +1,16 @@
|
|||
bright=`cat /sys/class/backlight/amdgpu_bl1/brightness`
|
||||
state=-1
|
||||
thresh=(1 2 3 4 5 6 8 10 13 16 21 27 34 44 57 73 94 120 155 199 255)
|
||||
|
||||
for i in ${!thresh[@]}; do
|
||||
if [ $bright -ge ${thresh[$i]} ]
|
||||
then
|
||||
state=$i
|
||||
fi
|
||||
done
|
||||
|
||||
new=$(($1 + $state))
|
||||
if [ $new -ge 0 ] && [ $new -le 20 ]
|
||||
then
|
||||
echo ${thresh[$new]} | tee /sys/class/backlight/amdgpu_bl1/brightness
|
||||
fi
|
||||
34
sway/chvol.sh
Executable file
34
sway/chvol.sh
Executable file
|
|
@ -0,0 +1,34 @@
|
|||
max=100
|
||||
|
||||
if [ $1 = 'source' ]; then
|
||||
object="@DEFAULT_AUDIO_SOURCE@"
|
||||
elif [ $1 = 'sink' ]; then
|
||||
object="@DEFAULT_AUDIO_SINK@"
|
||||
else
|
||||
exit 1
|
||||
fi;
|
||||
|
||||
if [ $2 = 'mute' ]; then
|
||||
wpctl set-mute $object toggle
|
||||
exit 0
|
||||
fi;
|
||||
|
||||
val=$(wpctl get-volume $object | awk '{print $2}')
|
||||
val=$(( (100*${val%%.*}) + ${val#*.} ))
|
||||
val=$(( $val + $2 ))
|
||||
|
||||
if [ $val -gt $max ]; then
|
||||
val=$max
|
||||
elif [ $val -lt 0 ]; then
|
||||
val=0
|
||||
fi;
|
||||
|
||||
|
||||
|
||||
dec=$(( val / 100 ))
|
||||
frac=$(( val % 100 ))
|
||||
if [ $frac -lt 10 ]; then
|
||||
frac="0$frac"
|
||||
fi
|
||||
|
||||
wpctl set-volume $object "$dec.$frac"
|
||||
66
sway/sway.nix
Normal file
66
sway/sway.nix
Normal file
|
|
@ -0,0 +1,66 @@
|
|||
{ lib, pkgs, config, ... }:
|
||||
let
|
||||
mod = "Mod4";
|
||||
chvol = pkgs.writeShellScript "chvol"
|
||||
(builtins.readFile ./chvol.sh);
|
||||
|
||||
in {
|
||||
wayland.windowManager.sway = {
|
||||
enable = true;
|
||||
config = {
|
||||
modifier = mod;
|
||||
terminal = "kitty";
|
||||
|
||||
# Waybar
|
||||
bars = [{
|
||||
command = "${pkgs.lib.getExe config.programs.waybar.package}";
|
||||
position = "top";
|
||||
fonts = config.wayland.windowManager.sway.config.fonts;
|
||||
}];
|
||||
|
||||
menu = "${pkgs.lib.getExe config.programs.rofi.package} -modes \"drun,run\" -show-icons -show drun";
|
||||
|
||||
keybindings = lib.mkOptionDefault ({
|
||||
# volume
|
||||
XF86AudioRaiseVolume = "exec bash ${chvol} sink 5";
|
||||
XF86AudioLowerVolume = "exec bash ${chvol} sink -5";
|
||||
XF86AudioMute = "exec bash ${chvol} sink mute";
|
||||
XF86AudioMicMute = "exec bash ${chvol} source mute";
|
||||
|
||||
# brightness
|
||||
# XF86MonBrightnessUp = "exec bash ${chbright} 1";
|
||||
# XF86MonBrightnessDown = "exec bash ${chbright} -1";
|
||||
|
||||
# media
|
||||
XF86AudioPlay = "exec playerctl play-pause";
|
||||
XF86AudioPrev = "exec playerctl previous";
|
||||
XF86AudioNext = "exec playerctl next";
|
||||
|
||||
|
||||
});
|
||||
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
# Waybar
|
||||
programs.waybar = {
|
||||
enable = true;
|
||||
};
|
||||
|
||||
|
||||
programs.rofi = {
|
||||
enable = true;
|
||||
};
|
||||
|
||||
qt = {
|
||||
enable = true;
|
||||
# style = {};
|
||||
};
|
||||
|
||||
gtk = {
|
||||
enable = true;
|
||||
# theme = {};
|
||||
};
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue