Sway support removed. Moved I38 specific scripts out of the branch covered by dex.
This commit is contained in:
+5
-13
@@ -54,8 +54,7 @@ class SystemCommands:
|
||||
}
|
||||
|
||||
optional_commands = {
|
||||
'xclip': 'Required for clipboard on X11',
|
||||
'wl-paste': 'Required for clipboard on Wayland',
|
||||
'xclip': 'Required for clipboard',
|
||||
'tesseract': 'Required for OCR functionality',
|
||||
}
|
||||
|
||||
@@ -1607,18 +1606,11 @@ class AiAssistant(Gtk.Window):
|
||||
def analyze_selected_in_thread():
|
||||
try:
|
||||
# First, try to get clipboard content (selected text)
|
||||
# Use wl-paste on Wayland, xclip on X11
|
||||
selected_text = ""
|
||||
if os.environ.get('WAYLAND_DISPLAY'):
|
||||
if SystemCommands.is_command_available('wl-paste'):
|
||||
clipboard_result = subprocess.run(['wl-paste', '-p'],
|
||||
capture_output=True, text=True, timeout=5)
|
||||
selected_text = clipboard_result.stdout.strip() if clipboard_result.returncode == 0 else ""
|
||||
else:
|
||||
if SystemCommands.is_command_available('xclip'):
|
||||
clipboard_result = subprocess.run(['xclip', '-o', '-selection', 'primary'],
|
||||
capture_output=True, text=True, timeout=5)
|
||||
selected_text = clipboard_result.stdout.strip() if clipboard_result.returncode == 0 else ""
|
||||
if SystemCommands.is_command_available('xclip'):
|
||||
clipboard_result = subprocess.run(['xclip', '-o', '-selection', 'primary'],
|
||||
capture_output=True, text=True, timeout=5)
|
||||
selected_text = clipboard_result.stdout.strip() if clipboard_result.returncode == 0 else ""
|
||||
|
||||
if selected_text:
|
||||
# We have selected text, analyze it
|
||||
|
||||
@@ -11,18 +11,11 @@
|
||||
# You should have received a copy of the GNU General Public License along with I38. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
path="$(readlink -f $0)"
|
||||
path="$(readlink -f "$0")"
|
||||
path="${path%/*/*}"
|
||||
path="${path##*/}"
|
||||
if [[ "$path" == "i3" ]]; then
|
||||
workSpace="$(i3-msg -t get_workspaces \
|
||||
| jq '.[] | select(.focused==true).name' \
|
||||
| cut -d"\"" -f2)"
|
||||
else
|
||||
workSpace="$(swaymsg -t get_workspaces \
|
||||
| jq '.[] | select(.focused==true).name' \
|
||||
| cut -d"\"" -f2)"
|
||||
fi
|
||||
workSpace="$(i3-msg -t get_workspaces \
|
||||
| jq '.[] | select(.focused==true).name' \
|
||||
| cut -d"\"" -f2)"
|
||||
left=9
|
||||
right=0
|
||||
msg="Workspace ${workSpace}"
|
||||
@@ -41,9 +34,9 @@ else
|
||||
right=9
|
||||
elif [[ ${workSpace} -gt 5 ]]; then
|
||||
right=9
|
||||
((left-=${workSpace}))
|
||||
((left-=workSpace))
|
||||
else
|
||||
((right+=${workSpace}))
|
||||
((right+=workSpace))
|
||||
fi
|
||||
fi
|
||||
play -nqV0 synth pi fade 0 .25 .15 pad 0 1 reverb overdrive riaa norm -8 speed 1 remix v0.${left} v0.${right} &
|
||||
|
||||
@@ -10,53 +10,25 @@
|
||||
|
||||
# You should have received a copy of the GNU General Public License along with I38. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
# Find out if we're using i3 or sway
|
||||
if ! [[ -n "${WAYLAND_DISPLAY}" ]]; then
|
||||
cmd="i3-msg"
|
||||
scratchConfig="${XDG_CONFIG_HOME:-$HOME/.config}/i3"
|
||||
usingWayland=false
|
||||
else
|
||||
cmd="swaymsg"
|
||||
scratchConfig="${XDG_CONFIG_HOME:-$HOME/.config}/sway"
|
||||
usingWayland=true
|
||||
fi
|
||||
scratchConfig="${XDG_CONFIG_HOME:-$HOME/.config}/i3"
|
||||
scratchConfig+="/scratchpad"
|
||||
touch "${scratchConfig}"
|
||||
|
||||
# Get the class name of the focused window
|
||||
if [[ "$usingWayland" == "true" ]]; then
|
||||
# Wayland/Sway: use swaymsg to get focused window info
|
||||
class=$($cmd -t get_tree | jq -r '.. | select(.focused? == true) | .app_id // .window_properties.class' | head -n 1)
|
||||
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}')
|
||||
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}')
|
||||
|
||||
if [[ -z "$class" ]]; then
|
||||
notify-send "Unable to move to scratchpad."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Check if it's already in the config
|
||||
if [[ "$usingWayland" == "true" ]]; then
|
||||
# Sway uses app_id for Wayland-native apps, class for XWayland apps
|
||||
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"
|
||||
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
|
||||
i3-msg "[class=\"$class\"] move to scratchpad"
|
||||
|
||||
+4
-36
@@ -20,29 +20,8 @@ trim_whitespace() {
|
||||
|
||||
get_shortcuts_file() {
|
||||
local configHome="${XDG_CONFIG_HOME:-$HOME/.config}"
|
||||
local candidatePath=
|
||||
local candidatePath="${configHome}/i3/desktop_shortcuts"
|
||||
|
||||
if [[ -n "${SWAYSOCK:-}" ]]; then
|
||||
candidatePath="${configHome}/sway/desktop_shortcuts"
|
||||
if [[ -r "$candidatePath" ]]; then
|
||||
printf '%s\n' "$candidatePath"
|
||||
return 0
|
||||
fi
|
||||
else
|
||||
candidatePath="${configHome}/i3/desktop_shortcuts"
|
||||
if [[ -r "$candidatePath" ]]; then
|
||||
printf '%s\n' "$candidatePath"
|
||||
return 0
|
||||
fi
|
||||
fi
|
||||
|
||||
candidatePath="${configHome}/i3/desktop_shortcuts"
|
||||
if [[ -r "$candidatePath" ]]; then
|
||||
printf '%s\n' "$candidatePath"
|
||||
return 0
|
||||
fi
|
||||
|
||||
candidatePath="${configHome}/sway/desktop_shortcuts"
|
||||
if [[ -r "$candidatePath" ]]; then
|
||||
printf '%s\n' "$candidatePath"
|
||||
return 0
|
||||
@@ -54,7 +33,6 @@ get_shortcuts_file() {
|
||||
build_launch_command() {
|
||||
local shortcutCommand="$1"
|
||||
local shortcutWorkspace="$2"
|
||||
local wmCommand=
|
||||
local workspaceEscaped=
|
||||
|
||||
if [[ -z "$shortcutWorkspace" ]]; then
|
||||
@@ -62,28 +40,18 @@ build_launch_command() {
|
||||
return 0
|
||||
fi
|
||||
|
||||
if [[ -n "${SWAYSOCK:-}" ]] && command -v swaymsg &> /dev/null; then
|
||||
wmCommand="swaymsg"
|
||||
elif [[ -n "${I3SOCK:-}" ]] && command -v i3-msg &> /dev/null; then
|
||||
wmCommand="i3-msg"
|
||||
elif [[ -n "${WAYLAND_DISPLAY:-}" ]] && command -v swaymsg &> /dev/null; then
|
||||
wmCommand="swaymsg"
|
||||
elif command -v i3-msg &> /dev/null; then
|
||||
wmCommand="i3-msg"
|
||||
fi
|
||||
|
||||
if [[ -z "$wmCommand" ]]; then
|
||||
if ! command -v i3-msg &> /dev/null; then
|
||||
printf '%s\n' "$shortcutCommand"
|
||||
return 0
|
||||
fi
|
||||
|
||||
if [[ "$shortcutWorkspace" =~ ^[0-9]+$ ]]; then
|
||||
printf '%s workspace number %s && %s\n' "$wmCommand" "$shortcutWorkspace" "$shortcutCommand"
|
||||
printf 'i3-msg workspace number %s && %s\n' "$shortcutWorkspace" "$shortcutCommand"
|
||||
return 0
|
||||
fi
|
||||
|
||||
workspaceEscaped=$(printf '%q' "$shortcutWorkspace")
|
||||
printf '%s workspace %s && %s\n' "$wmCommand" "$workspaceEscaped" "$shortcutCommand"
|
||||
printf 'i3-msg workspace %s && %s\n' "$workspaceEscaped" "$shortcutCommand"
|
||||
}
|
||||
|
||||
desktopPath="${HOME}/Desktop"
|
||||
|
||||
+13
-44
@@ -19,58 +19,27 @@
|
||||
|
||||
set -e
|
||||
|
||||
# Detect if we're on Wayland or X11
|
||||
if [[ -n "${WAYLAND_DISPLAY}" ]]; then
|
||||
usingWayland=true
|
||||
else
|
||||
usingWayland=false
|
||||
fi
|
||||
|
||||
get_kbdlayout() {
|
||||
if [[ "$usingWayland" == "true" ]]; then
|
||||
# Sway: Get keyboard layout from input devices
|
||||
# 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
|
||||
layout=$(setxkbmap -query | grep -oP 'layout:\s*\K([\w,]+)')
|
||||
variant=$(setxkbmap -query | grep -oP 'variant:\s*\K(\w+)')
|
||||
echo "$layout" "$variant"
|
||||
}
|
||||
|
||||
set_kbdlayout() {
|
||||
eval "array=($1)"
|
||||
read -r -a array <<< "$1"
|
||||
|
||||
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
|
||||
setxkbmap "${array[@]}" &&
|
||||
spd-say -P important -Cw "${array[@]}"
|
||||
}
|
||||
|
||||
cycle() {
|
||||
if [[ "$usingWayland" == "true" ]]; then
|
||||
# Sway: Just switch to next layout (Sway handles cycling internally)
|
||||
swaymsg input type:keyboard xkb_switch_layout next
|
||||
currentLayout=$(get_kbdlayout)
|
||||
spd-say -P important -Cw "$currentLayout"
|
||||
else
|
||||
# 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
|
||||
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"
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -65,18 +65,6 @@ case "$powerAction" in
|
||||
esac
|
||||
|
||||
try_logout() {
|
||||
if [[ -n "${SWAYSOCK:-}" ]] && command -v swaymsg &> /dev/null; then
|
||||
swaymsg -t command exit &> /dev/null
|
||||
return $?
|
||||
fi
|
||||
if [[ -n "${I3SOCK:-}" ]] && command -v i3-msg &> /dev/null; then
|
||||
i3-msg -t command exit &> /dev/null
|
||||
return $?
|
||||
fi
|
||||
if command -v swaymsg &> /dev/null; then
|
||||
swaymsg -t command exit &> /dev/null
|
||||
return $?
|
||||
fi
|
||||
if command -v i3-msg &> /dev/null; then
|
||||
i3-msg -t command exit &> /dev/null
|
||||
return $?
|
||||
|
||||
+18
-20
@@ -42,7 +42,7 @@ add_reminder() {
|
||||
done
|
||||
info="${info#|#}"
|
||||
# Get information for reminder into an array
|
||||
IFS='|' read -a reminder <<< $info
|
||||
IFS='|' read -r -a reminder <<< "$info"
|
||||
# Fix time to be 2 digits.
|
||||
[[ ${#reminder[3]} -eq 1 ]] && reminder[3]="0${reminder[3]}"
|
||||
[[ ${#reminder[4]} -eq 1 ]] && reminder[4]="0${reminder[4]}"
|
||||
@@ -83,7 +83,7 @@ add_custom_reminder() {
|
||||
done
|
||||
info="${info#|#}"
|
||||
# Get information for reminder into an array
|
||||
IFS='|' read -a reminder <<< $info
|
||||
IFS='|' read -r -a reminder <<< "$info"
|
||||
if [[ "${reminder[0]}" != "# " ]]; then
|
||||
echo "# ${reminder[0]}" >> ~/.reminders
|
||||
fi
|
||||
@@ -112,7 +112,7 @@ add_daily_reminder() {
|
||||
fi
|
||||
|
||||
# Get information for reminder into an array
|
||||
IFS='|' read -a reminder <<< $info
|
||||
IFS='|' read -r -a reminder <<< "$info"
|
||||
|
||||
# Fix time to be 2 digits.
|
||||
[[ ${#reminder[1]} -eq 1 ]] && reminder[1]="0${reminder[1]}"
|
||||
@@ -153,7 +153,7 @@ add_monthly_reminder() {
|
||||
fi
|
||||
|
||||
# Get information for reminder into an array
|
||||
IFS='|' read -a reminder <<< $info
|
||||
IFS='|' read -r -a reminder <<< "$info"
|
||||
|
||||
# Fix time and date to be 2 digits.
|
||||
[[ ${#reminder[2]} -eq 1 ]] && reminder[2]="0${reminder[2]}"
|
||||
@@ -205,7 +205,7 @@ add_weekly_reminder() {
|
||||
fi
|
||||
|
||||
# Get information for reminder into an array
|
||||
IFS='|' read -a reminder <<< $info
|
||||
IFS='|' read -r -a reminder <<< "$info"
|
||||
|
||||
# Fix time to be 2 digits.
|
||||
[[ ${#reminder[9]} -eq 1 ]] && reminder[9]="0${reminder[9]}"
|
||||
@@ -272,27 +272,28 @@ view_reminders() {
|
||||
done
|
||||
|
||||
# Display the reminders
|
||||
reminder="$(yad --list --title "I38 - Reminders" --text "Current reminders:" \
|
||||
selectedReminder="$(yad --list --title "I38 - Reminders" --text "Current reminders:" \
|
||||
--column "Reminder" "${yadMenu[@]}" \
|
||||
--button="Close!gtk-ok:1" --button="Delete!gtk-delete:0" --response=1)"
|
||||
if [[ $? -ne 0 ]]; then
|
||||
yadResult=$?
|
||||
if [[ $yadResult -ne 0 ]]; then
|
||||
return
|
||||
fi
|
||||
if [[ "${reminder:0:1}" == "#" ]]; then
|
||||
if [[ "${selectedReminder:0:1}" == "#" ]]; then
|
||||
error "Please select the actual reminder to be deleted, anything starting with # is only a comment. Nothing changed."
|
||||
return
|
||||
fi
|
||||
# Remove the | from the end of reminder
|
||||
reminder="${reminder%|}"
|
||||
selectedReminder="${selectedReminder%|}"
|
||||
# Find the index to remove from lines.
|
||||
for i in "${!yadMenu[@]}" ; do
|
||||
if [[ "${yadMenu[i]}" == "${reminder}" ]]; then
|
||||
if [[ "${yadMenu[i]}" == "${selectedReminder}" ]]; then
|
||||
# Delete selected reminder and possible preceeding comment.
|
||||
commentIndex=$((i - 1))
|
||||
if [[ "${lines[commentIndex]:0:1}" == "#" ]]; then
|
||||
unset lines[$commentIndex]
|
||||
unset "lines[$commentIndex]"
|
||||
fi
|
||||
unset lines[$i]
|
||||
unset "lines[$i]"
|
||||
message "Reminder deleted."
|
||||
printf "%s\n" "${lines[@]}" > ~/.reminders
|
||||
fi
|
||||
@@ -330,11 +331,7 @@ if [[ $# -ne 0 ]]; then
|
||||
url="${url%[[:space:].?!]}"
|
||||
fi
|
||||
if [[ "${#url}" -gt 3 ]]; then
|
||||
# Copy URL to clipboard using appropriate tool
|
||||
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
|
||||
if 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
|
||||
@@ -347,7 +344,7 @@ if [[ $# -ne 0 ]]; then
|
||||
fi
|
||||
|
||||
while : ; do
|
||||
action=$(yad --title "I38 - Reminders" --form \
|
||||
yad --title "I38 - Reminders" --form \
|
||||
--button="_View Today's Reminders!gtk-info":3 \
|
||||
--button="_View All Reminders!gtk-info":4 \
|
||||
--button="_Add Reminder!gtk-edit":0 \
|
||||
@@ -356,9 +353,10 @@ while : ; do
|
||||
--button="Add Monthly Reminder!gtk-edit":6 \
|
||||
--button="Add Custom Reminder!gtk-edit":7 \
|
||||
--button="Close!gtk-cancel":1 \
|
||||
--separator="")
|
||||
--separator=""
|
||||
yadResult=$?
|
||||
|
||||
case $? in
|
||||
case $yadResult in
|
||||
0)
|
||||
# Single reminder
|
||||
add_reminder
|
||||
|
||||
@@ -10,24 +10,12 @@
|
||||
|
||||
# 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.
|
||||
# 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)"
|
||||
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)"
|
||||
|
||||
menuOptions=(
|
||||
"1.0" "Maximum Brightness"
|
||||
@@ -43,28 +31,7 @@ if [[ ${#brightness} -lt 1 ]]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# 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
|
||||
xrandr --output "${screenName}" --brightness "${brightness%%|*}" &&
|
||||
spd-say -P important -Cw "Screen set to ${brightness#*|}."
|
||||
|
||||
exit 0
|
||||
|
||||
+8
-17
@@ -39,28 +39,19 @@ if ! command -v sha512sum &> /dev/null; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
wmMsg="i3-msg"
|
||||
if [[ -n "${SWAYSOCK:-}" ]] && command -v swaymsg &> /dev/null; then
|
||||
wmMsg="swaymsg"
|
||||
elif [[ -n "${I3SOCK:-}" ]] && command -v i3-msg &> /dev/null; then
|
||||
wmMsg="i3-msg"
|
||||
elif command -v swaymsg &> /dev/null; then
|
||||
wmMsg="swaymsg"
|
||||
elif command -v i3-msg &> /dev/null; then
|
||||
wmMsg="i3-msg"
|
||||
else
|
||||
yad --title "I38" --text "No i3 or sway command interface was found for screen lock." --button "Close:0"
|
||||
if ! command -v i3-msg &> /dev/null; then
|
||||
yad --title "I38" --text "No i3 command interface was found for screen lock." --button "Close:0"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
currentWorkspace="$($wmMsg -t get_workspaces | jq -r '.[] | select(.focused==true) | .name')"
|
||||
currentWorkspace="$(i3-msg -t get_workspaces | jq -r '.[] | select(.focused==true) | .name')"
|
||||
lockWorkspace="i38-lock"
|
||||
if $wmMsg -t get_workspaces | jq -e --arg name "$lockWorkspace" '.[] | select(.name==$name)' &> /dev/null; then
|
||||
if i3-msg -t get_workspaces | jq -e --arg name "$lockWorkspace" '.[] | select(.name==$name)' &> /dev/null; then
|
||||
lockWorkspace="i38-lock-$$"
|
||||
fi
|
||||
|
||||
$wmMsg -t command "workspace --no-auto-back-and-forth \"$lockWorkspace\"" &> /dev/null
|
||||
$wmMsg -t command "mode screenlock" &> /dev/null
|
||||
i3-msg -t command "workspace --no-auto-back-and-forth \"$lockWorkspace\"" &> /dev/null
|
||||
i3-msg -t command "mode screenlock" &> /dev/null
|
||||
|
||||
attemptCount=0
|
||||
while : ; do
|
||||
@@ -92,9 +83,9 @@ while : ; do
|
||||
attemptCount=$((attemptCount + 1))
|
||||
done
|
||||
|
||||
$wmMsg -t command "mode default" &> /dev/null
|
||||
i3-msg -t command "mode default" &> /dev/null
|
||||
if [[ -n "$currentWorkspace" ]]; then
|
||||
$wmMsg -t command "workspace \"$currentWorkspace\"" &> /dev/null
|
||||
i3-msg -t command "workspace \"$currentWorkspace\"" &> /dev/null
|
||||
fi
|
||||
|
||||
exit 0
|
||||
|
||||
+1
-29
@@ -11,10 +11,6 @@
|
||||
# You should have received a copy of the GNU General Public License along with I38. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
path="$(readlink -f $0)"
|
||||
path="${path%/*/*}"
|
||||
path="${path##*/}"
|
||||
if [[ "$path" == "i3" ]]; then
|
||||
mapfile -t windowList < <(python3 -c '
|
||||
import i3ipc
|
||||
|
||||
@@ -28,28 +24,4 @@ id="$(yad --title "I38" --list --separator "" --column "id" --column "Select Win
|
||||
if [[ -z "${id}" ]]; then
|
||||
exit 0
|
||||
fi
|
||||
i3-msg \[id="${id}"\] focus
|
||||
else
|
||||
mapfile -t windowList < <(python3 -c '
|
||||
import i3ipc
|
||||
|
||||
i3 = i3ipc.Connection()
|
||||
|
||||
for con in i3.get_tree():
|
||||
if con.window or con.type == "con":
|
||||
if con.name:
|
||||
print(con.window)
|
||||
print(con.name)')
|
||||
|
||||
# Remove the first entry if it is "none"
|
||||
if [[ "${windowList[0]}" == "none" ]]; then
|
||||
unset "windowList[0]"
|
||||
fi
|
||||
|
||||
id="$(yad --title "I38" --list --separator "" --column "id" --column "Select Window" --hide-column 1 --print-column 1 "${windowList[@]}")"
|
||||
|
||||
if [[ -z "${id}" ]]; then
|
||||
exit 0
|
||||
fi
|
||||
swaymsg \[id="${id}"\] focus
|
||||
fi
|
||||
i3-msg \[id="${id}"\] focus
|
||||
|
||||
Reference in New Issue
Block a user