#!/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 . scratchConfig="${XDG_CONFIG_HOME:-$HOME/.config}/i3" scratchConfig+="/scratchpad" touch "${scratchConfig}" # Get the class name of the focused window 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 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"