This commit is contained in:
2024-01-08 20:50:29 +01:00
commit 2fb62acda6
121 changed files with 16413 additions and 0 deletions
+108
View File
@@ -0,0 +1,108 @@
#!/usr/bin/env bash
MONITOR1=HDMI-1
MONITOR2=DP-2
version=0.0.1
help() {
echo "bspwm window titles"
echo "allows you to have bspwm window titles from each monitor in your bar"
echo "-------------------"
echo
echo "Syntax: bspwm_window_titles [-i <FILE_PATH>|m|p|f <FORMAT_FOCUSED|NORMAL>|V]"
echo "options:"
echo "h Print this help."
echo "i <FILE_PATH> Icon map path - custom path to file containing icon map"
echo "v Print software version and exit."
echo
}
add_desktop() {
desktop_id="`cat $HOME/.cache/bspwm_focused_desktop`"
monitor_id=$(bspc query -M -m '.focused' --names)
current_amount=$(cat $HOME/.cache/bspwm_desktop_count_"$monitor_id")
let new_id=current_amount+1
max=4
if [[ $current_amount -lt $max ]]; then
bspc monitor $monitor_id -a "$new_id"
echo $new_id > $HOME/.cache/bspwm_desktop_count_"$monitor_id"
fi
}
init() {
bspc monitor ${MONITOR1} -d 1
bspc monitor ${MONITOR2} -d 5
echo 1 > $HOME/.cache/bspwm_desktop_count_"$MONITOR1"
echo 1 > $HOME/.cache/bspwm_desktop_count_"$MONITOR2"
### node_remove event
### removes empty desktops
bspc subscribe node_remove | while read line
do
monitor_id=$(echo "$line" | awk '{print $2}')
desktop_id=$(echo "$line" | awk '{print $3}')
windowlist=$( bspc query -N -n .window -m "$monitor_id" -d "$desktop_id" )
desktopname=$( bspc query -D -m "$monitor_id" -d "$desktop_id" --names )
### check if desktop is empty
if [[ -z "$windowlist" ]]; then
bspc desktop -r
fi
done
### write focused desktop id to cache file
bspc subscribe desktop_focus | while read line
do
desktop_id=$(echo "$line" | awk '{print $3}')
echo $desktop_id > $HOME/.cache/bspwm_focused_desktop
done
### write desktop amount to cache file
bspc subscribe desktop_add | while read line
do
monitor_id=$(echo "$line" | awk '{print $2}')
monitor_name $(bspc query -M -m "$monitor_id" --names)
desktop_id=$(echo "$line" | awk '{print $3}')
desktops=$(bspc query -D -m "$monitor_id" --names)
count=0
echo "$desktops" | sed 's/ //g' | while read l
do
((count++))
echo $count
echo $count > $HOME/.cache/bspwm_desktop_count_"$monitor_name"
done
done
}
while getopts ":haiv:" option; do
case $option in
h)
help
exit;;
a)
add_desktop
exit;;
i)
init
exit;;
v)
echo "Version $version";
exit;;
*)
echo "Error: Invalid option"
exit;;
esac
done
help
exit
+60
View File
@@ -0,0 +1,60 @@
#!/bin/bash
# A more fluid way of moving windows with BSPWM, which is meant to be
# implemented in SXHKD. If there is a window in the given direction,
# swap places with it. Else if there is a receptacle move to it
# ("consume" its place). Otherwise create a receptacle in the given
# direction by splitting the entire viewport (circumvents the tiling
# scheme while respecting the current split ratio configuration). In
# the latter scenario, inputting the direction twice will thus move the
# focused window out of its current layout and into the receptacle.
#
# Part of my dotfiles: https://gitlab.com/protesilaos/dotfiles
#
# Copyright (c) 2019 Protesilaos Stavrou <info@protesilaos.com>
#
# This program 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.
#
# This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
[ "$#" -eq 1 ] || { echo "Pass only one argument: north,east,south,west"; exit 1; }
# Check if argument is a valid direction.
case "$1" in
north|east|south|west)
dir="$1"
;;
*)
echo "Not a valid argument."
echo "Use one of: north,east,south,west"
exit 1
;;
esac
_query_nodes() {
bspc query -N -n "$@"
}
# Do not operate on floating windows!
[ -z "$(_query_nodes focused.floating)" ] || { echo "Only move tiled windows."; exit 1; }
receptacle="$(_query_nodes 'any.leaf.!window')"
# This regulates the behaviour documented in the description.
if [ -n "$(_query_nodes "${dir}.!floating")" ]; then
bspc node -s "$dir"
elif [ -n "$receptacle" ]; then
bspc node focused -n "$receptacle" --follow
else
bspc node @/ -p "$dir" -i && bspc node -n "$receptacle" --follow
fi
+160
View File
@@ -0,0 +1,160 @@
#!/usr/bin/env bash
# globals
version="1.1"
cache_path="${HOME}/.cache"
icon_map_path="$( dirname "$( readlink -f "$0" )" )/bspwm_window_titles_icon_map.txt"
# defaults
polybar_mode="true"
monocle_mode="false"
# format_focused="%{F#2e3440}%{T4}%{T- F-}%{B#2e3440}{NAME}%{B-}%{F#2e3440}%{T4}%{T- F-}"
# format_normal="%{F#20212C}%{T4}%{T- F-}%{B#20212C}%{F#5D5E72}{NAME}%{B-}%{F#20212C}%{T4}%{T- F-}"
format_focused="{NAME}"
format_normal="%{F#5D5E72}{NAME}%{F-}"
# wraps a text with polybar format command action
# $1 action
# $2 text
polybar_action_cmd() {
echo "%{A1:${1}:}${2}%{A}"
}
# formats window name with given format
# $1 format
# $2 window name
polybar_format_window_name() {
echo "$1" | sed "s@{NAME}@$2@"
}
help() {
echo "bspwm window titles"
echo "allows you to have bspwm window titles from each monitor in your bar"
echo "-------------------"
echo
echo "Syntax: bspwm_window_titles [-i <FILE_PATH>|m|p|f <FORMAT_FOCUSED|NORMAL>|V]"
echo "options:"
echo "h Print this help."
echo "i <FILE_PATH> Icon map path - custom path to file containing icon map"
echo "m Monocle mode - won't print window names when there is only one window on desktop."
echo "p Polybar action mode - will output window names wrapped with polybar action handlers."
echo " This allows you to directly click on a window name to focus it's window"
echo "f <FORMAT_FOCUSED|NORMAL> Format how focused/normal window names are displayed"
echo " You need to supply both polybar format tags (so need to use -f two times)"
echo " Example"
echo " bspwm_window_titles -f \"%{F#f00}{NAME}%{F-}\" -f \"{NAME}\""
echo " focused window name font color red and normal window as is"
echo "V Print software version and exit."
echo
}
while getopts ":hvmpf:i:" option; do
case $option in
h)
help
exit;;
m)
monocle_mode="true";;
i)
icon_map_path="$OPTARG";;
p)
polybar_mode="true";;
f)
formats+=("$OPTARG");
[[ -n ${formats[0]} ]] && format_focused="${formats[0]}"
[[ -n ${formats[1]} ]] && format_normal="${formats[1]}";;
v)
echo "Version $version";
exit;;
*)
echo "Error: Invalid option"
exit;;
esac
done
icon_map=$( cat "${icon_map_path}" )
# subscribe to events on which the window title list will get updated
bspc subscribe node_focus node_remove desktop_focus | while read -r _; do
# get all monitors
monitors=$( bspc query -M )
for monitor in $monitors; do
index=$((index + 1))
# get last focused desktop on given monitor
last_focused_desktop=$( bspc query -D -m "$monitor" -d .active )
# get windows from last focused desktop on given monitor
winids_on_desktop=$( bspc query -N -n .window -m "$monitor" -d "$last_focused_desktop" )
# get number of windows on desktop
number_of_windows=$( printf "$winids_on_desktop" | tr '\n' ' ' | wc -w )
# get a list of all windows
winlist=$( wmctrl -l -x )
for window_id in $winids_on_desktop; do
# replace all spaces and tabs with single spaces for easier cutting
window=$( echo "$winlist" | grep -i "$window_id" | tr -s '[:blank:]' )
# get window name
window_name=$( echo "$window" | cut -d " " -f 5- )
# longer window titles if there is only one window
[[ "$number_of_windows" == "1" ]] && char_cut="40" || char_cut="20"
# cut the window name
window_name_short=$( echo "$window_name" | cut -c1-"$char_cut" )
# get window class and match after a dot to get app name
window_class=$( echo "$window" | cut -d " " -f 3 | sed 's/.*\.//')
# if window id matched with list == not empty
if [[ -n "$window_name" ]]; then
# trim window name
window_name=$( echo "$window_name_short" | sed -e 's/^[[:space:]]*//' )
# display instance name if there is no window title
if [[ "$window_name" == "N/A" ]]; then
window_name=$(echo "$window" | cut -d " " -f 3 | cut -d "." -f 2 )
fi
# get icon for class name
window_icon=$( grep "$window_class" <<< "$icon_map" | cut -d " " -f2 )
# fallback icon if class not found
if [[ -z "$window_icon" ]]; then
window_icon=$( grep "Fallback" <<< "$icon_map" | cut -d " " -f2 )
fi
# join icon and name
window_name_with_icon="${window_icon} ${window_name}"
# apply formatting
if [[ $( bspc query -N -n focused) == "$window_id" ]]; then
formatted_window_name=$( polybar_format_window_name "$format_focused" "$window_name_with_icon" )
else
formatted_window_name=$( polybar_format_window_name "$format_normal" "$window_name_with_icon" )
fi
# wrap with polybar action cmd
[[ "$polybar_mode" == "true" ]] && formatted_window_name=$( polybar_action_cmd "bspc node -f ${window_id}" "$formatted_window_name")
curr_wins+="${formatted_window_name} "
fi
done
# if monocle set to true then don't print names if there is only one
if [[ "$monocle_mode" == "true" && "$number_of_windows" == "1" ]]; then
windows_print=""
else
windows_print="$curr_wins"
fi
# print out the window names to files for use in a bar
echo "$windows_print" > "${cache_path}/bspwm_windows_${index}.txt"
unset curr_wins
done
unset index
done
@@ -0,0 +1,11 @@
Google-chrome 
firefox 
Code 
Slack 
kitty 
Nautilus 
Nemo 
Viewnior 
Celluloid 
Audacious 
Fallback 󰘔
+116
View File
@@ -0,0 +1,116 @@
#! /bin/sh
# -- start hotkey daemon
pgrep -x sxhkd > /dev/null || sxhkd &
xrandr --output HDMI-1 --mode 2560x1440 --rate 144
xrandr --output HDMI-1 --primary
xrandr --output HDMI-1 --left-of DP-2
# -- BSPWM Settings
bspc monitor HDMI-1 -d 1 2 3
bspc monitor DP-2 -d 4 5 6
bspc config border_width 2
bspc config window_gap 4
bspc config split_ratio 0.50
bspc config borderless_monocle true
bspc config gapless_monocle true
bspc config single_monocle true
bspc config presel_feedback_color "#5D5E72"
bspc config normal_border_color "#1e1e2e"
bspc config active_border_color "#1e1e2e"
bspc config focused_border_color "#45475a"
bspc config focus_follows_pointer true
bspc config pointer_follows_focus true
bspc config pointer_follows_monitor true
# -- BSPWM Rules
bspc rule -a kitty-vpn state=center_pseudo_tiled follow=on
bspc rule -a NoiseTorch state=floating center=on
#bspc rule -a "microsoft teams - preview" desktop=4
#bspc rule -a Lutris desktop='^3'
#bspc rule -a battle.net.exe desktop='^3'
#bspc rule -a discord desktop='^6'
#bspc rule -a "VirtualBox Machine" state=floating desktop='^2'
#bspc rule -a Kupfer.py focus=on
#bspc rule -a Screenkey manage=off
bspc rule -a "Conky:Conky:conky*" flag=sticky layer=below state=floating sticky=on
# -- Autostart
# restart window titles daemon
cat /dev/null > $HOME/.cache/bspwm_windows_1.txt
cat /dev/null > $HOME/.cache/bspwm_windows_2.txt
while pgrep -u $UID -f bspwm_window_titles >/dev/null; do pkill -f bspwm_window_titles; done
bspwm_window_titles &
## -- launch polybar
$HOME/.config/polybar/launch.sh
roficlip.py --daemon &
## -- policy kit
#pgrep -x lxsession > /dev/null || lxsession &
pgrep -x lxpolkit > /dev/null || lxpolkit &
## -- launch dunst notification server
pgrep -x dunst > /dev/null || dunst &
## -- set the default cursor to left pointer
xsetroot -cursor_name left_ptr &
## -- start the compositor
#pgrep -x picom > /dev/null || picom --config $HOME/.config/picom/picom.conf --experimental-backends --backend glx &
pgrep -x picom > /dev/null || picom &
## -- udisk utils
#udisksvm >/dev/null &
pgrep -x udiskie > /dev/null || udiskie &
## -- noisetorch noise cancelling
#noisetorch -u
#pgrep -x noisetorch > /dev/null || noisetorch -i sys-devices-pci0000:00-0000:00:01.3-0000:02:00.0-usb2-2\x2d10-2\x2d10:1.0-sound-card3-controlC3.device -s alsa_input.usb-Corsair_CORSAIR_HS70_Pro_Wireless_Gaming_Headset-00.mono-fallback -t 70 &
# -- Autostart of misc
## -- applets
#nm-applet --indicator &
#blueman-applet &
#pgrep -x indicator-sound-switcher > /dev/null || indicator-sound-switcher &
#/home/dom/.local/share/headset-charge-indicator/headset-charge-indicator.py &
#/home/dom/.local/share/media-control-indicator/media-control-indicator.py &
# -- Set background wallpaper
#nitrogen --restore &
feh --bg-scale ~/Pictures/Wallpaper/MonarchOS.png &
###
### remove picom corners in monocle mode
### https://www.reddit.com/r/bspwm/comments/hqt1r3/is_there_a_way_to_disable_picom_rounded_borders/
###
bspc subscribe desktop_layout | while read -r Event
do
Desktop=$(echo "$Event" | awk '{print $3}')
State=$(echo "$Event" | awk '{print $4}')
if [ "$State" = "monocle" ]; then
bspc query -N -d $Desktop | while read -r Node
do
xprop -id $Node -f _PICOM_ROUNDED 32c -set _PICOM_ROUNDED 1
done
elif [ $(bspc config window_gap) -gt 0 ]; then
bspc query -N -d $Desktop | while read -r Node
do
xprop -id $Node -remove _PICOM_ROUNDED
done
fi
done &
+1
View File
@@ -0,0 +1 @@
kitty