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:
Storm Dragon
2025-12-01 02:24:20 -05:00
parent fa9a6f3c7d
commit 63be4fc9e7
7 changed files with 1805 additions and 55 deletions

View File

@@ -42,10 +42,35 @@ scrot: For OCR
- x11bell: [optional] Bell support if you do not have a PC speaker. Available from https://github.com/jovanlanik/x11bell - x11bell: [optional] Bell support if you do not have a PC speaker. Available from https://github.com/jovanlanik/x11bell
- xbacklight: [optional] for screen brightness adjustment - xbacklight: [optional] for screen brightness adjustment
- xclip: Clipboard support - xclip: Clipboard support
- xfce4-notifyd: For sending notifications. Replaces notification-daemon (Sway users will need to install the customized variant at <https://github.com/icasdri/xfce4-notifyd-layer-shell>) - xfce4-notifyd: For sending notifications. Replaces notification-daemon
- xorg-setxkbmap: [optional] for multiple keyboard layouts - xorg-setxkbmap: [optional] for multiple keyboard layouts
- yad: For screen reader accessible dialogs - yad: For screen reader accessible dialogs
### Sway/Wayland Specific Dependencies
When using I38 with Sway instead of i3, the following Wayland-native alternatives are recommended for optimal compatibility. I38 will automatically detect and use these when running with the `-s` flag:
- **Recommended (Wayland-native)**:
- mako: Wayland-native notification daemon (preferred over xfce4-notifyd)
- wl-clipboard: Wayland clipboard utilities (provides wl-copy and wl-paste)
- clipman: Wayland clipboard manager (works with wl-clipboard)
- wlr-randr: [optional] Wayland display configuration tool for screen brightness control
- brightnessctl: [optional] Alternative brightness control tool for Sway
- **Not needed on Sway/Wayland** (these are X11-only):
- xbrlapi: X11 braille helper - not needed on Wayland, BRLTTY works directly
- x11bell: X11 bell support - Wayland has native alternatives
- clipster: X11 clipboard manager - use clipman/wl-clipboard instead
- xdotool: X11 window manipulation - Sway uses native IPC instead
- xprop: X11 window properties - Sway uses native IPC instead
- xrandr: X11 display configuration - use wlr-randr or brightnessctl instead
- setxkbmap: X11 keyboard layout - Sway uses native input configuration
- **Works on both** (via XWayland fallback if Wayland-native not available):
- xfce4-notifyd: Works via XWayland, but mako is preferred for native Wayland support
**Note**: On Sway, keyboard layouts must be configured in the Sway config file (`~/.config/sway/config`) using the `input` block. The keyboard.sh script will cycle through configured layouts but cannot set layouts directly like on X11.
### AI Assistant (Optional) ### AI Assistant (Optional)
- python-requests: For Ollama integration - python-requests: For Ollama integration
- claude: [optional] Claude Code CLI for Claude AI integration. Install from https://claude.ai/code - claude: [optional] Claude Code CLI for Claude AI integration. Install from https://claude.ai/code

54
i38.sh
View File

@@ -883,20 +883,36 @@ $(if [[ $sounds -eq 0 ]]; then
echo "exec_always --no-startup-id ${i3Path}/scripts/sound.py" echo "exec_always --no-startup-id ${i3Path}/scripts/sound.py"
fi fi
fi fi
if [[ $brlapi -eq 0 ]]; then # xbrlapi is X11-only, skip on Sway/Wayland
if [[ $brlapi -eq 0 ]] && [[ $usingSway -ne 0 ]]; then
echo 'exec --no-startup-id xbrlapi --quiet' echo 'exec --no-startup-id xbrlapi --quiet'
fi fi
if [[ $udiskie -eq 0 ]]; then if [[ $udiskie -eq 0 ]]; then
echo 'exec --no-startup-id udiskie' echo 'exec --no-startup-id udiskie'
fi fi
if [[ -x "/usr/lib/xfce4/notifyd/xfce4-notifyd" ]]; then # Notification daemon
echo 'exec_always --no-startup-id /usr/lib/xfce4/notifyd/xfce4-notifyd' if [[ $usingSway -eq 0 ]]; then
elif [[ -x "/usr/lib/notification-daemon-1.0/notification-daemon" ]]; then # Sway: prefer Wayland-native notification daemons
echo 'exec_always --no-startup-id /usr/lib/notification-daemon-1.0/notification-daemon -r' if command -v mako &> /dev/null; then
fi echo 'exec_always --no-startup-id mako'
# Work around for weird Void Linux stuff. elif [[ -x "/usr/lib/xfce4/notifyd/xfce4-notifyd" ]]; then
if [[ -x "/usr/libexec/notification-daemon" ]]; then # Fallback to X11 variant via XWayland
echo 'exec_always --no-startup-id /usr/libexec/notification-daemon -r' echo 'exec_always --no-startup-id /usr/lib/xfce4/notifyd/xfce4-notifyd'
elif [[ -x "/usr/lib/notification-daemon-1.0/notification-daemon" ]]; then
echo 'exec_always --no-startup-id /usr/lib/notification-daemon-1.0/notification-daemon -r'
elif [[ -x "/usr/libexec/notification-daemon" ]]; then
echo 'exec_always --no-startup-id /usr/libexec/notification-daemon -r'
fi
else
# i3: use X11 notification daemons
if [[ -x "/usr/lib/xfce4/notifyd/xfce4-notifyd" ]]; then
echo 'exec_always --no-startup-id /usr/lib/xfce4/notifyd/xfce4-notifyd'
elif [[ -x "/usr/lib/notification-daemon-1.0/notification-daemon" ]]; then
echo 'exec_always --no-startup-id /usr/lib/notification-daemon-1.0/notification-daemon -r'
elif [[ -x "/usr/libexec/notification-daemon" ]]; then
# Work around for weird Void Linux stuff
echo 'exec_always --no-startup-id /usr/libexec/notification-daemon -r'
fi
fi fi
if command -v remind &> /dev/null && command -v notify-send &> /dev/null ; then if command -v remind &> /dev/null && command -v notify-send &> /dev/null ; then
echo "exec_always --no-startup-id ${i3Path}/scripts/launch_remind.sh" echo "exec_always --no-startup-id ${i3Path}/scripts/launch_remind.sh"
@@ -908,13 +924,27 @@ fi
if [[ $dex -eq 0 ]]; then if [[ $dex -eq 0 ]]; then
echo '# Start XDG autostart .desktop files using dex. See also' echo '# Start XDG autostart .desktop files using dex. See also'
echo '# https://wiki.archlinux.org/index.php/XDG_Autostart' echo '# https://wiki.archlinux.org/index.php/XDG_Autostart'
echo 'exec --no-startup-id dex --autostart --environment i3' if [[ $usingSway -eq 0 ]]; then
echo 'exec --no-startup-id dex --autostart --environment sway'
else
echo 'exec --no-startup-id dex --autostart --environment i3'
fi
else else
echo '# Startup applications' echo '# Startup applications'
if command -v x11bell &> /dev/null ; then # x11bell is X11-only, skip on Sway/Wayland
if command -v x11bell &> /dev/null && [[ $usingSway -ne 0 ]]; then
echo 'exec --no-startup-id x11bell play -nqV0 synth .1 sq norm -12' echo 'exec --no-startup-id x11bell play -nqV0 synth .1 sq norm -12'
fi fi
echo 'exec --no-startup-id clipster -d' # Clipboard manager
if [[ $usingSway -eq 0 ]]; then
# Sway: use Wayland clipboard manager
if command -v wl-paste &> /dev/null && command -v clipman &> /dev/null; then
echo 'exec wl-paste -t text --watch clipman store'
fi
else
# i3: use X11 clipboard manager
echo 'exec --no-startup-id clipster -d'
fi
echo "exec $screenReader" echo "exec $screenReader"
echo "exec_always --no-startup-id ${i3Path}/scripts/desktop.sh" echo "exec_always --no-startup-id ${i3Path}/scripts/desktop.sh"
fi) fi)

1600
scripts/ai.py Executable file

File diff suppressed because it is too large Load Diff

View File

@@ -1,21 +1,31 @@
#!/usr/bin/env bash #!/usr/bin/env bash
# Find out if we're using i3 # Find out if we're using i3 or sway
if ! [[ -n "${WAYLAND_DISPLAY}" ]]; then if ! [[ -n "${WAYLAND_DISPLAY}" ]]; then
cmd="i3-msg" cmd="i3-msg"
scratchConfig="${XDG_CONFIG_HOME:-$HOME/.config}/i3" scratchConfig="${XDG_CONFIG_HOME:-$HOME/.config}/i3"
usingWayland=false
else else
cmd="swaymsg" cmd="swaymsg"
scratchConfig="${XDG_CONFIG_HOME:-$HOME/.config}/sway" scratchConfig="${XDG_CONFIG_HOME:-$HOME/.config}/sway"
usingWayland=true
fi fi
scratchConfig+="/scratchpad" scratchConfig+="/scratchpad"
touch "${scratchConfig}" touch "${scratchConfig}"
# Get the focused window ID # Get the class name of the focused window
windowId=$(xdotool getactivewindow) if [[ "$usingWayland" == "true" ]]; then
# Wayland/Sway: use swaymsg to get focused window info
# Get the class name of the window class=$($cmd -t get_tree | jq -r '.. | select(.focused? == true) | .app_id // .window_properties.class' | head -n 1)
class=$(xprop -id "$windowId" WM_CLASS | awk -F '"' '{print $4}') else
# X11/i3: use xdotool and xprop
if ! command -v xdotool &> /dev/null || ! command -v xprop &> /dev/null; then
notify-send "Error: xdotool and xprop required for i3"
exit 1
fi
windowId=$(xdotool getactivewindow)
class=$(xprop -id "$windowId" WM_CLASS | awk -F '"' '{print $4}')
fi
if [[ -z "$class" ]]; then if [[ -z "$class" ]]; then
notify-send "Unable to move to scratchpad." notify-send "Unable to move to scratchpad."
@@ -23,10 +33,20 @@ if [[ -z "$class" ]]; then
fi fi
# Check if it's already in the config # Check if it's already in the config
if ! grep -q "class=\"$class\"" "$scratchConfig"; then if [[ "$usingWayland" == "true" ]]; then
echo "for_window [class=\"$class\"] move to scratchpad" >> "$scratchConfig" # Sway uses app_id for Wayland-native apps, class for XWayland apps
notify-send "Added window class $class to scratchpad" if ! grep -q "app_id=\"$class\"" "$scratchConfig" && ! grep -q "class=\"$class\"" "$scratchConfig"; then
echo "for_window [app_id=\"$class\"] move to scratchpad" >> "$scratchConfig"
notify-send "Added window app_id $class to scratchpad"
fi
# Move the window to scratchpad now (try both app_id and class)
$cmd "[app_id=\"$class\"] move to scratchpad" 2>/dev/null || $cmd "[class=\"$class\"] move to scratchpad"
else
# i3 uses class
if ! grep -q "class=\"$class\"" "$scratchConfig"; then
echo "for_window [class=\"$class\"] move to scratchpad" >> "$scratchConfig"
notify-send "Added window class $class to scratchpad"
fi
# Move the window to scratchpad now
$cmd "[class=\"$class\"] move to scratchpad"
fi fi
# Move the window to scratchpad now
$cmd "[class=\"$class\"] move to scratchpad"

View File

@@ -1,16 +1,16 @@
#!/usr/bin/env bash #!/usr/bin/env bash
# This file is part of I38. # 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, # 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. # 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 # 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. # 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/>. # You should have received a copy of the GNU General Public License along with I38. If not, see <https://www.gnu.org/licenses/>.
# This script is a modified version of i3-keyboard-layout. # This script is a modified version of i3-keyboard-layout.
# Originally Copyright (c) 2018 Sergio Gil. # Originally Copyright (c) 2018 Sergio Gil.
# https://github.com/porras/i3-keyboard-layout # https://github.com/porras/i3-keyboard-layout
@@ -19,26 +19,58 @@
set -e set -e
# Detect if we're on Wayland or X11
if [[ -n "${WAYLAND_DISPLAY}" ]]; then
usingWayland=true
else
usingWayland=false
fi
get_kbdlayout() { get_kbdlayout() {
layout=$(setxkbmap -query | grep -oP 'layout:\s*\K([\w,]+)') if [[ "$usingWayland" == "true" ]]; then
variant=$(setxkbmap -query | grep -oP 'variant:\s*\K(\w+)') # Sway: Get keyboard layout from input devices
echo "$layout" "$variant" # This gets the xkb_active_layout_name from the first keyboard
layout=$(swaymsg -t get_inputs | jq -r '.[] | select(.type=="keyboard") | .xkb_active_layout_name' | head -n 1)
echo "$layout"
else
# i3: Use setxkbmap
layout=$(setxkbmap -query | grep -oP 'layout:\s*\K([\w,]+)')
variant=$(setxkbmap -query | grep -oP 'variant:\s*\K(\w+)')
echo "$layout" "$variant"
fi
} }
set_kbdlayout() { set_kbdlayout() {
eval "array=($1)" eval "array=($1)"
setxkbmap "${array[@]}" &&
spd-say -P important -Cw "${array[@]}" if [[ "$usingWayland" == "true" ]]; then
# Sway: Switch to next keyboard layout
# Sway cycles through layouts configured in the config, so we just trigger next
swaymsg input type:keyboard xkb_switch_layout next &&
spd-say -P important -Cw "${array[@]}"
else
# i3: Use setxkbmap
setxkbmap "${array[@]}" &&
spd-say -P important -Cw "${array[@]}"
fi
} }
cycle() { cycle() {
current_layout=$(get_kbdlayout | xargs) if [[ "$usingWayland" == "true" ]]; then
layouts=("$@" "$1") # add the first one at the end so that it cycles # Sway: Just switch to next layout (Sway handles cycling internally)
index=0 swaymsg input type:keyboard xkb_switch_layout next
while [ "${layouts[$index]}" != "$current_layout" ] && [ $index -lt "${#layouts[@]}" ]; do index=$[index +1]; done currentLayout=$(get_kbdlayout)
next_index=$[index +1] spd-say -P important -Cw "$currentLayout"
next_layout=${layouts[$next_index]} else
set_kbdlayout "$next_layout" # i3: Cycle through provided layouts
currentLayout=$(get_kbdlayout | xargs)
layouts=("$@" "$1") # add the first one at the end so that it cycles
index=0
while [ "${layouts[$index]}" != "$currentLayout" ] && [ $index -lt "${#layouts[@]}" ]; do index=$((index + 1)); done
nextIndex=$((index + 1))
nextLayout=${layouts[$nextIndex]}
set_kbdlayout "$nextLayout"
fi
} }
@@ -47,7 +79,7 @@ shift || exit 1
case $subcommand in case $subcommand in
"get") "get")
echo -n $(get_kbdlayout) echo -n "$(get_kbdlayout)"
;; ;;
"cycle") "cycle")
cycle "$@" cycle "$@"

View File

@@ -329,9 +329,17 @@ if [[ $# -ne 0 ]]; then
notification="${notification/${url}[[:space:]]/}" notification="${notification/${url}[[:space:]]/}"
url="${url%[[:space:].?!]}" url="${url%[[:space:].?!]}"
fi fi
if command -v xclip &> /dev/null && [[ "${#url}" -gt 3 ]]; then if [[ "${#url}" -gt 3 ]]; then
echo "${url}" | xclip -selection clipboard # Copy URL to clipboard using appropriate tool
notify-send --hint=int:transient:1 -t 500 -r 38 "${notification} The URL has been copied to the clipboard." if [[ -n "${WAYLAND_DISPLAY}" ]] && command -v wl-copy &> /dev/null; then
echo "${url}" | wl-copy
notify-send --hint=int:transient:1 -t 500 -r 38 "${notification} The URL has been copied to the clipboard."
elif command -v xclip &> /dev/null; then
echo "${url}" | xclip -selection clipboard
notify-send --hint=int:transient:1 -t 500 -r 38 "${notification} The URL has been copied to the clipboard."
else
notify-send --hint=int:transient:1 -t 500 -r 38 "${*}"
fi
else else
notify-send --hint=int:transient:1 -t 500 -r 38 "${*}" notify-send --hint=int:transient:1 -t 500 -r 38 "${*}"
fi fi

View File

@@ -1,19 +1,33 @@
#!/usr/bin/env bash #!/usr/bin/env bash
# This file is part of I38. # 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, # 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. # 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 # 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. # 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/>. # 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. # Not for multiple screens.
# Get the name of the screen. # Detect if we're on Wayland or X11
screenName="$(xrandr --query | grep "connected" | cut -d ' ' -f1 | head -n 1)" 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=( menuOptions=(
"1.0" "Maximum Brightness" "1.0" "Maximum Brightness"
@@ -29,7 +43,28 @@ if [[ ${#brightness} -lt 1 ]]; then
exit 0 exit 0
fi fi
xrandr --output ${screenName} --brightness ${brightness%%|*} && # Apply brightness setting
spd-say -P important -Cw "Screen set to ${brightness#*|}." 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 exit 0