Switch to SwayFX
This commit is contained in:
parent
6571feaff7
commit
c310042564
41 changed files with 1450 additions and 294 deletions
81
hosts/totsugeki/home-manager/scripts/change-wallpaper.nix
Normal file
81
hosts/totsugeki/home-manager/scripts/change-wallpaper.nix
Normal file
|
@ -0,0 +1,81 @@
|
|||
{ pkgs }:
|
||||
|
||||
pkgs.writeShellApplication {
|
||||
name = "change-wallpaper";
|
||||
runtimeInputs = with pkgs; [ dunst rofi swww ];
|
||||
text = ''
|
||||
shopt -s nullglob
|
||||
|
||||
WALLPAPER_PATH="$HOME/.local/share/wallpapers"
|
||||
WALLPAPERS=("$WALLPAPER_PATH"/*)
|
||||
|
||||
if [ ! -f "$WALLPAPER_PATH/.current_path" ]; then
|
||||
# Current wallpaper file does not exist, create it
|
||||
echo "''${WALLPAPERS[0]}" > "$WALLPAPER_PATH/.current_path"
|
||||
fi
|
||||
|
||||
CURRENT_WALLPAPER=$(cat "$WALLPAPER_PATH/.current_path")
|
||||
CURRENT_WP_INDEX=-1
|
||||
# Get the current wallpaper's index
|
||||
for index in "''${!WALLPAPERS[@]}"; do
|
||||
if [ "''${WALLPAPERS[$index]}" = "$CURRENT_WALLPAPER" ]; then
|
||||
CURRENT_WP_INDEX=$index
|
||||
fi
|
||||
done
|
||||
|
||||
if [ "$CURRENT_WP_INDEX" -eq -1 ]; then
|
||||
CURRENT_WP_INDEX=0
|
||||
fi
|
||||
|
||||
if [ "$1" = "previous" ]; then
|
||||
WALLPAPER="''${WALLPAPERS[$CURRENT_WP_INDEX - 1]}"
|
||||
TRANSITION_ANGLE=300
|
||||
elif [ "$1" = "next" ]; then
|
||||
NEXT_INDEX=$((CURRENT_WP_INDEX + 1))
|
||||
if [ "$NEXT_INDEX" = "''${#WALLPAPERS[@]}" ]; then
|
||||
NEXT_INDEX=0
|
||||
fi
|
||||
WALLPAPER=''${WALLPAPERS[$NEXT_INDEX]}
|
||||
TRANSITION_ANGLE=120
|
||||
elif [ "$1" = "open-menu" ]; then
|
||||
INPUT=""
|
||||
for index in "''${!WALLPAPERS[@]}"; do
|
||||
if [ "$index" = "$CURRENT_WP_INDEX" ]; then
|
||||
continue
|
||||
fi
|
||||
_WALLPAPER=''${WALLPAPERS[$index]}
|
||||
_WALLPAPER_NAME=$(basename "$_WALLPAPER")
|
||||
INPUT+="$_WALLPAPER_NAME\0icon\x1f$_WALLPAPER"
|
||||
if [ ! $((index + 1)) -eq ''${#WALLPAPERS[@]} ]; then
|
||||
INPUT+=$'\n'
|
||||
fi
|
||||
done
|
||||
if ! WALLPAPER=$(echo -en "$INPUT" | rofi -dmenu -mesg "Cambiar fondo de pantalla" -p "" -i -theme ~/.config/rofi/wallpaper_selector.rasi); then
|
||||
exit 1
|
||||
fi
|
||||
WALLPAPER="$WALLPAPER_PATH/$WALLPAPER"
|
||||
TRANSITION_ANGLE=270
|
||||
else
|
||||
echo "Unknown first argument: $1"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -z "$WALLPAPER" ]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
WALLPAPER_NAME=$(basename "$WALLPAPER")
|
||||
echo "Setting wallpaper to $WALLPAPER"
|
||||
echo "$WALLPAPER" > "$WALLPAPER_PATH/.current_path"
|
||||
ln -sf "$WALLPAPER" "$WALLPAPER_PATH/.current_image"
|
||||
dunstify -i "$WALLPAPER" -t 2800 "Cambiando fondo de pantalla" "Cambiando a $WALLPAPER_NAME"
|
||||
swww img\
|
||||
--transition-type wipe\
|
||||
--transition-angle $TRANSITION_ANGLE\
|
||||
--transition-step 90\
|
||||
--transition-duration 1\
|
||||
--transition-fps 165\
|
||||
"$WALLPAPER"
|
||||
|
||||
'';
|
||||
}
|
51
hosts/totsugeki/home-manager/scripts/ddc-brightness.nix
Normal file
51
hosts/totsugeki/home-manager/scripts/ddc-brightness.nix
Normal file
|
@ -0,0 +1,51 @@
|
|||
{ pkgs }:
|
||||
pkgs.writeShellApplication {
|
||||
# Only for GIGABYTE G32QC monitor
|
||||
name = "ddc-brightness";
|
||||
runtimeInputs = with pkgs; [ ddcutil ];
|
||||
text = ''
|
||||
usage() {
|
||||
echo "Usage: ddc-brightness VALUE"
|
||||
echo "Possible values are +X, -X or X"
|
||||
exit 1
|
||||
}
|
||||
BRIGHTNESS_REGEX="^(-|\+)*[0-9]+$"
|
||||
test -n 1 || usage
|
||||
CACHE_FILE="/run/user/$UID/current-brightness"
|
||||
CURRENT_BRIGHTNESS=0
|
||||
if [ -f "$CACHE_FILE" ]; then
|
||||
CURRENT_BRIGHTNESS=$(cat "$CACHE_FILE")
|
||||
else
|
||||
CURRENT_BRIGHTNESS=$(ddcutil getvcp 10 | tr -s " " | cut -d " " -f 9 | tr -d ",")
|
||||
echo "$CURRENT_BRIGHTNESS" > "$CACHE_FILE"
|
||||
fi
|
||||
echo "Current brightness level is $CURRENT_BRIGHTNESS"
|
||||
if [[ ! "$1" =~ $BRIGHTNESS_REGEX ]]; then
|
||||
echo "Invalid value: '$1'"
|
||||
exit 1
|
||||
fi
|
||||
NEW_BRIGHTNESS_VALUE=0
|
||||
if [ "''${1:0:1}" == "+" ]; then
|
||||
NEW_BRIGHTNESS_VALUE=$(("$CURRENT_BRIGHTNESS" + "''${1:1}"))
|
||||
elif [ "''${1:0:1}" == "-" ]; then
|
||||
NEW_BRIGHTNESS_VALUE=$(("$CURRENT_BRIGHTNESS" - "''${1:1}"))
|
||||
else
|
||||
NEW_BRIGHTNESS_VALUE="$1"
|
||||
fi
|
||||
if [ "$NEW_BRIGHTNESS_VALUE" -lt 0 ]; then
|
||||
NEW_BRIGHTNESS_VALUE=0
|
||||
elif [ "$NEW_BRIGHTNESS_VALUE" -gt 100 ]; then
|
||||
NEW_BRIGHTNESS_VALUE=100
|
||||
fi
|
||||
echo "$NEW_BRIGHTNESS_VALUE" > "$CACHE_FILE"
|
||||
echo "Setting brightness level to $NEW_BRIGHTNESS_VALUE"
|
||||
ddcutil setvcp 10 "$NEW_BRIGHTNESS_VALUE"
|
||||
dunstify \
|
||||
--appname "volumectl"\
|
||||
--replace 9002\
|
||||
--urgency low\
|
||||
--timeout 1250\
|
||||
--hints "int:value:$NEW_BRIGHTNESS_VALUE"\
|
||||
" $NEW_BRIGHTNESS_VALUE%"
|
||||
'';
|
||||
}
|
|
@ -1,6 +1,10 @@
|
|||
{ pkgs, ... }: {
|
||||
home.packages = with pkgs; [
|
||||
home.packages = [
|
||||
(import ./change-wallpaper.nix { inherit pkgs; })
|
||||
(import ./ddc-brightness.nix { inherit pkgs; })
|
||||
(import ./play-on-soundboard.nix { inherit pkgs; })
|
||||
(import ./screenshot.nix { inherit pkgs; })
|
||||
(import ./setup-soundboard.nix { inherit pkgs; })
|
||||
(import ./volumectl.nix { inherit pkgs; })
|
||||
];
|
||||
}
|
||||
|
|
36
hosts/totsugeki/home-manager/scripts/screenshot.nix
Normal file
36
hosts/totsugeki/home-manager/scripts/screenshot.nix
Normal file
|
@ -0,0 +1,36 @@
|
|||
{ pkgs }:
|
||||
|
||||
pkgs.writeShellApplication {
|
||||
name = "screenshot";
|
||||
runtimeInputs = with pkgs; [
|
||||
dunst
|
||||
grim
|
||||
libjxl
|
||||
slurp
|
||||
wl-clipboard
|
||||
xdg-user-dirs
|
||||
];
|
||||
text = ''
|
||||
usage() {
|
||||
echo "Usage: screenshot { full | section }"
|
||||
exit 1
|
||||
}
|
||||
|
||||
test -n 1 || usage
|
||||
|
||||
FILE_NAME=$(date +'Screenshot_%Y%m%d_%H%M%S')
|
||||
TEMPORARY_PATH="/tmp/$FILE_NAME.png"
|
||||
SCREENSHOT_PATH="$(xdg-user-dir PICTURES)/Capturas/$FILE_NAME.jxl"
|
||||
if [ "$1" == "full" ]; then
|
||||
grim "$TEMPORARY_PATH"
|
||||
elif [ "$1" == "section" ]; then
|
||||
grim -g "$(slurp -b '#000000aa' -w 0)" "$TEMPORARY_PATH"
|
||||
else
|
||||
usage
|
||||
fi
|
||||
wl-copy < "$TEMPORARY_PATH"
|
||||
cjxl "$TEMPORARY_PATH" "$SCREENSHOT_PATH"
|
||||
dunstify --raw_icon="$TEMPORARY_PATH" "Captura de pantalla realizada" "Guardada como $FILE_NAME.jxl"
|
||||
rm "$TEMPORARY_PATH"
|
||||
'';
|
||||
}
|
65
hosts/totsugeki/home-manager/scripts/volumectl.nix
Normal file
65
hosts/totsugeki/home-manager/scripts/volumectl.nix
Normal file
|
@ -0,0 +1,65 @@
|
|||
{ pkgs }:
|
||||
pkgs.writeShellApplication {
|
||||
name = "volumectl";
|
||||
runtimeInputs = with pkgs; [ dunst pamixer ];
|
||||
text = ''
|
||||
VOLUME_REGEX="^(-*|\+*)[0-9]+$"
|
||||
volume=""
|
||||
|
||||
if [ "$1" == "output" ]; then
|
||||
if [[ "$2" =~ $VOLUME_REGEX ]]; then
|
||||
if [ "$(pamixer --get-mute)" == "true" ]; then
|
||||
pamixer --unmute > /dev/null
|
||||
fi
|
||||
if [ "''${2:0:1}" == "-" ]; then
|
||||
pamixer --allow-boost -d "''${2:1}" > /dev/null
|
||||
elif [ "''${2:0:1}" == "+" ]; then
|
||||
pamixer --allow-boost -i "''${2:1}" > /dev/null
|
||||
fi
|
||||
volume="$(pamixer --get-volume-human)"
|
||||
message=" $volume"
|
||||
elif [ "$2" == "toggle-mute" ]; then
|
||||
if [ "$(pamixer --get-mute)" == "true" ]; then
|
||||
pamixer --unmute > /dev/null
|
||||
volume="$(pamixer --get-volume-human)"
|
||||
message=" $volume"
|
||||
else
|
||||
pamixer --mute > /dev/null
|
||||
message=" Silenciado"
|
||||
fi
|
||||
else
|
||||
message="volumectl error: Unknown second argument"
|
||||
fi
|
||||
elif [ "$1" == "input" ]; then
|
||||
if [[ "$2" =~ $VOLUME_REGEX ]]; then
|
||||
if [ "$(pamixer --default-source --get-mute)" == "true" ]; then
|
||||
pamixer --default-source --unmute > /dev/null
|
||||
fi
|
||||
if [ "''${2:0:1}" == "-" ];then
|
||||
pamixer --default-source --allow-boost -d "''${2:1}" > /dev/null
|
||||
elif [ "''${2:0:1}" == "+" ]; then
|
||||
pamixer --default-source --allow-boost -i "''${2:1}" > /dev/null
|
||||
fi
|
||||
volume="$(pamixer --default-source --get-volume-human)"
|
||||
message=" $volume"
|
||||
elif [ "$2" == "toggle-mute" ]; then
|
||||
if [ "$(pamixer --default-source --get-mute)" == "true" ]; then
|
||||
pamixer --default-source --unmute > /dev/null
|
||||
volume="$(pamixer --default-source --get-volume-human)"
|
||||
message=" $volume"
|
||||
else
|
||||
pamixer --default-source --mute > /dev/null
|
||||
message=" Silenciado"
|
||||
fi
|
||||
else
|
||||
message="volumectl error: Unknown second argument"
|
||||
fi
|
||||
else
|
||||
message="volumectl error: Unknown first argument"
|
||||
fi
|
||||
|
||||
volume="$(echo "$volume" | tr -d "%")"
|
||||
|
||||
dunstify --appname "volumectl" --replace 9001 --urgency low --timeout 1250 --hints "int:value:$volume" "$message"
|
||||
'';
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue