tightened up Sway support. There shouldn't be any bugs, but with something like this you never know. I3 users should certainly not encounter any bugs from these changes, please yell if something weird happens.
Oh, and finally pushed the ai.py script I have been using for some time without pushing. I guess several months of testing should be fine. lol
This commit is contained in:
@@ -1,19 +1,33 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# This file is part of I38.
|
||||
|
||||
|
||||
# I38 is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation,
|
||||
# either version 3 of the License, or (at your option) any later version.
|
||||
|
||||
|
||||
# I38 is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
# PURPOSE. See the GNU General Public License for more details.
|
||||
|
||||
|
||||
# You should have received a copy of the GNU General Public License along with I38. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
|
||||
|
||||
# Not for multiple screens.
|
||||
# Get the name of the screen.
|
||||
screenName="$(xrandr --query | grep "connected" | cut -d ' ' -f1 | head -n 1)"
|
||||
# Detect if we're on Wayland or X11
|
||||
if [[ -n "${WAYLAND_DISPLAY}" ]]; then
|
||||
# Sway/Wayland: Get the name of the first output
|
||||
screenName="$(swaymsg -t get_outputs | jq -r '.[0].name')"
|
||||
if [[ -z "$screenName" ]]; then
|
||||
notify-send "Error: Could not detect output"
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
# i3/X11: Get the name of the screen
|
||||
if ! command -v xrandr &> /dev/null; then
|
||||
notify-send "Error: xrandr not found"
|
||||
exit 1
|
||||
fi
|
||||
screenName="$(xrandr --query | grep "connected" | cut -d ' ' -f1 | head -n 1)"
|
||||
fi
|
||||
|
||||
menuOptions=(
|
||||
"1.0" "Maximum Brightness"
|
||||
@@ -29,7 +43,28 @@ if [[ ${#brightness} -lt 1 ]]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
xrandr --output ${screenName} --brightness ${brightness%%|*} &&
|
||||
spd-say -P important -Cw "Screen set to ${brightness#*|}."
|
||||
# Apply brightness setting
|
||||
if [[ -n "${WAYLAND_DISPLAY}" ]]; then
|
||||
# Sway: Use swaymsg to set output brightness
|
||||
# Note: Sway doesn't have native brightness control, using wlr-randr if available
|
||||
if command -v wlr-randr &> /dev/null; then
|
||||
wlr-randr --output "${screenName}" --brightness "${brightness%%|*}" &&
|
||||
spd-say -P important -Cw "Screen set to ${brightness#*|}."
|
||||
else
|
||||
# Fallback to gamma adjustment via wl-gammactl or brightnessctl
|
||||
if command -v brightnessctl &> /dev/null; then
|
||||
brightnessValue=$(echo "${brightness%%|*} * 100" | bc)
|
||||
brightnessctl set "${brightnessValue%.*}%" &&
|
||||
spd-say -P important -Cw "Screen set to ${brightness#*|}."
|
||||
else
|
||||
notify-send "Error: wlr-randr or brightnessctl required for Sway brightness control"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
else
|
||||
# i3: Use xrandr
|
||||
xrandr --output "${screenName}" --brightness "${brightness%%|*}" &&
|
||||
spd-say -P important -Cw "Screen set to ${brightness#*|}."
|
||||
fi
|
||||
|
||||
exit 0
|
||||
|
||||
Reference in New Issue
Block a user