diff --git a/bin/WindowSelector b/bin/WindowSelector new file mode 100755 index 0000000..9945445 --- /dev/null +++ b/bin/WindowSelector @@ -0,0 +1,16 @@ +#!/bin/bash +# Script copied from AUR package dswitcher, and modified for theming and placement and removed unnecessary functions. +if ! [ -f "$HOME/.dmenurc" ]; then + cp /usr/share/dmenu/dmenurc $HOME/.dmenurc +fi +. $HOME/.dmenurc + +width=$(wattr w $(lsw -r)) +height=$(wattr h $(lsw -r)) +bar_width=$(( $width / 3 )) +left_shift=$(( ($width - $bar_width) / 2 )) +top_shift=$PANEL_HEIGHT + +num=$(wmctrl -l | sed 's/ / /' | cut -d " " -f 4- | nl -w 3 -n rn | sed -r 's/^([ 0-9]+)[ \t]*(.*)$/\1 - \2/' | dmenu -i -l 10 -x $left_shift -y $top_shift -w $bar_width -fn $DMENU_FN -nb $DMENU_NB -nf $DMENU_NF -sf $DMENU_SF -sb $DMENU_SB | cut -d '-' -f -1) +[[ -z "$num" ]] && exit +wmctrl -l | sed -n "$num p" | cut -c -10 | xargs wmctrl -i -a diff --git a/bin/bspwm_rename_desktop b/bin/bspwm_rename_desktop new file mode 100755 index 0000000..f3a50cc --- /dev/null +++ b/bin/bspwm_rename_desktop @@ -0,0 +1,13 @@ +#!/bin/bash + +DMENU_NF="#A3A6AB" +DMENU_NB="#34322E" +DMENU_SF="#F6F9FF" +DMENU_SB="#5C5955" + +DESKTOP_NAME=`echo '' | dmenu -b $DMENU_THEME -p 'Rename:'` +if [ -z $DESKTOP_NAME ]; then + exit 0 +fi + +bspc desktop -n "$DESKTOP_NAME" diff --git a/bin/bspwm_resize.sh b/bin/bspwm_resize.sh new file mode 100755 index 0000000..b935126 --- /dev/null +++ b/bin/bspwm_resize.sh @@ -0,0 +1,41 @@ +#!/bin/bash + +size=${2:-'10'} +dir=$1 + +# Find current window mode +is_tiled() { +bspc query -T -n | grep -q '"state":"tiled"' +} +# If the window is floating, move it +if ! is_tiled; then +#only parse input if window is floating,tiled windows accept input as is + case "$dir" in + west) switch="-w" + sign="-" + ;; + east) switch="-w" + sign="+" + ;; + north) switch="-h" + sign="-" + ;; + south) switch="-h" + sign="+" + ;; + esac + xdo resize ${switch} ${sign}${size} + +# Otherwise, window is tiled: switch with window in given direction +else + case "$dir" in + west) bspc node @west -r -$size || bspc node @east -r -${size} + ;; + east) bspc node @west -r +$size || bspc node @east -r +${size} + ;; + north) bspc node @south -r -$size || bspc node @north -r -${size} + ;; + south) bspc node @south -r +$size || bspc node @north -r +${size} + ;; + esac +fi diff --git a/bin/chwp b/bin/chwp new file mode 100755 index 0000000..d6d1049 --- /dev/null +++ b/bin/chwp @@ -0,0 +1,3 @@ +#!/bin/sh + +/home/tonitch/.fehbg diff --git a/bin/colorshow b/bin/colorshow new file mode 100755 index 0000000..794c1d1 --- /dev/null +++ b/bin/colorshow @@ -0,0 +1,9 @@ +for x in {0..8}; do + for i in {30..37}; do + for a in {40..47}; do + echo -ne "\e[$x;$i;$a""m\\\e[$x;$i;$a""m\e[0;37;40m " + done + echo + done +done +echo "" diff --git a/bin/dmenu_recent b/bin/dmenu_recent new file mode 100755 index 0000000..47dcb51 --- /dev/null +++ b/bin/dmenu_recent @@ -0,0 +1,73 @@ +#!/bin/bash + +# Originally based on code by Dieter Plaetinck. +# Pretty much re-written by Mina Nagy (mnzaki) + +if ! [ -f "$HOME/.dmenurc" ]; then + cp /usr/share/dmenu/dmenurc $HOME/.dmenurc +fi +. $HOME/.dmenurc + +#dmenu_cmd="dmenu $DMENU_OPTIONS" +dmenu_cmd="dmenu $DMENU_OPTIONS" +terminal="$TERMINAL -e" +max_recent=199 # Number of recent commands to track + +cache_dir="${XDG_CACHE_HOME:-$HOME/.cache}/dmenu-recent" +recent_cache="$cache_dir/recent" +rest_cache="$cache_dir/all" +known_types=" background terminal terminal_hold " + +config_dir="${XDG_CONFIG_HOME:-$HOME/.config}/dmenu-recent" +mkdir -p "$cache_dir" +mkdir -p "$config_dir" +touch "$recent_cache" + +# Without this, it won't remember $type +GREP_OPTIONS='--color=never' + +IFS=: +if stest -dqr -n "$rest_cache" $PATH 2>/dev/null; then + stest -flx $PATH | sort -u | grep -vf "$recent_cache" > "$rest_cache" +fi + +IFS=" " +cmd=$(cat "$recent_cache" "$rest_cache" | $dmenu_cmd -p run: "$@") || exit + +if ! grep -qx "$cmd" "$recent_cache" &> /dev/null; then + grep -vx "$cmd" "$rest_cache" > "$rest_cache.$$" + mv "$rest_cache.$$" "$rest_cache" +fi + +echo "$cmd" > "$recent_cache.$$" +grep -vx "$cmd" "$recent_cache" | head -n "$max_recent" >> "$recent_cache.$$" +mv "$recent_cache.$$" "$recent_cache" + +# Figure out how to run the command based on the command name, disregarding +# arguments, if any. +word0=${cmd%% *} +match="^$word0$" + +get_type () { + while type=$(echo $known_types | xargs -n1 | $dmenu_cmd -p Type:); do + [[ $known_types =~ " $type " ]] || continue + echo "$word0" >> "$config_dir/$type" + break + done + echo $type +} + +if ! type=$(grep -lx "$match" -R "$config_dir"); then + type=$(get_type) +else + type=${type##*/} + if ! [[ $known_types =~ " $type " ]]; then + rm "$config_dir/$type" + type=$(get_type) + fi +fi + +[[ "$type" = "background" ]] && exec $cmd +[[ "$type" = "terminal" ]] && exec $TERMINAL -e "$cmd" +[[ "$type" = "terminal_hold" ]] && + exec $TERMINAL -e sh -c "$cmd && echo Press Enter to kill me... && read line" diff --git a/bin/emoji b/bin/emoji new file mode 100755 index 0000000..8c60f08 --- /dev/null +++ b/bin/emoji @@ -0,0 +1,22 @@ +#!/bin/sh +# Give dmenu list of all unicode characters to copy. +# Shows the selected character in dunst if running. + +# Must have xclip installed to even show menu. +xclip -h >/dev/null || exit + +if [ -e ~/.config/fontawesome ]; then + chosen=$(grep -v "#" -h ~/.config/emoji ~/.config/fontawesome | dmenu -i -l 20 -fn Monospace-18) +else + chosen=$(grep -v "#" ~/.config/emoji | dmenu -i -l 20 -fn Monospace-18) +fi + +[ "$chosen" != "" ] || exit + +c=$(echo "$chosen" | sed "s/ .*//") +echo "$c" | tr -d '\n' | xclip -sel clip +notify-send "'$c' copied to clipboard." & + +s=$(echo "$chosen" | sed "s/.*; //" | awk '{print $1}') +echo "$s" | tr -d '\n' | xclip +notify-send "'$s' copied to primary." & diff --git a/bin/euclid_balancer b/bin/euclid_balancer new file mode 100755 index 0000000..13eb5ba --- /dev/null +++ b/bin/euclid_balancer @@ -0,0 +1,14 @@ +#!/bin/dash + +if [ "$(pgrep -cx euclid_balancer)" -gt 1 ] ; then + killall euclid_balancer && exit 0 +else + +bspc subscribe node_add node_remove node_state node_geometry | while read line; do + for wid in $(bspc query -N -d -n .window); do + bspc node "${wid}#@north" -B || true + bspc node "${wid}#@south" -B || true + done +done + +fi diff --git a/bin/euclid_mode b/bin/euclid_mode new file mode 100755 index 0000000..d2fe3c5 --- /dev/null +++ b/bin/euclid_mode @@ -0,0 +1,15 @@ +#! /bin/sh + +fwid=$(bspc query -N -n focused.automatic) +wid=$1 +class=$2 +instance=$3 +title=$(xtitle "$wid") +#floats=$(bspc query -N -n .local.floating | wc -l) +if bspc query -N -n "@/.!automatic" > /dev/null ; then + echo "node=@/" +fi +if [ -n "$fwid" ] ; then + echo "split_dir=south" +fi +#window-placer $floats $wid diff --git a/bin/euclid_mover b/bin/euclid_mover new file mode 100755 index 0000000..93fe470 --- /dev/null +++ b/bin/euclid_mover @@ -0,0 +1,85 @@ +#!/bin/bash +# Originally by https://github.com/windelicato/ + +size=${2:-'20'} +dir=$1 + +transplanter() { + bspc node ${dir} -p south && bspc node -n ${dir} +} + +northplanter() { + bspc node north -p north && bspc node -n north +} + +rootplanter() { + bspc node @/ -p ${dir} && bspc node -n @/ || bspc node -s next.local && bspc node -n @/ + bspc node @/ -p cancel +} + +bspc config pointer_follows_focus true +# Find current window mode +is_floating() { +bspc query -T -n | grep -q '"state":"floating"' +} +# If the window is floating, move it +if is_floating; then +#only parse input if window is floating,tiled windows accept input as is + case "$dir" in + west) switch="-x" + sign="-" + ;; + east) switch="-x" + sign="+" + ;; + north) switch="-y" + sign="-" + ;; + *) switch="-y" + sign="+" + ;; + esac + xdo move ${switch} ${sign}${size} + +# Otherwise, window is tiled: switch with window in given direction +else + if [[ $(bspc query -N -n .local.\!floating | wc -l) != 2 ]]; then + case "$dir" in + north) northplanter || rootplanter + ;; + *) transplanter || rootplanter + ;; + esac + else + case "$dir" in + east) bspc node -s east || bspc query -N -n west.local || \ + if bspc query -N -n south.local ; then + bspc node @/ -R 90 + else + bspc node @/ -R 270 + fi + ;; + west) bspc node -s west || bspc query -N -n east.local || \ + if bspc query -N -n north.local ; then + bspc node @/ -R 90 + else + bspc node @/ -R 270 + fi + ;; + south) bspc node -s south || bspc query -N -n north.local || \ + if bspc query -N -n west.local ; then + bspc node @/ -R 90 + else + bspc node @/ -R 270 + fi + ;; + *) bspc node -s north || bspc query -N -n south.local || \ + if bspc query -N -n west.local ; then + bspc node @/ -R 270 + else + bspc node @/ -R 90 + fi + ;; + esac + fi +fi diff --git a/bin/focusmover b/bin/focusmover new file mode 100755 index 0000000..f3936be --- /dev/null +++ b/bin/focusmover @@ -0,0 +1,13 @@ +#!/bin/sh +#Focus windows by direction, works with multihead +#called like this in sxhkdrc: +#super + {a,s,w,d} +# focusmover {west,south,north,east} + bspc config pointer_follows_monitor true; \ + bspc config pointer_follows_focus true; \ + dir=$@; \ + if ! bspc node -f $dir; then \ + bspc monitor -f $dir; \ + fi; \ + bspc config pointer_follows_monitor false; \ + bspc config pointer_follows_focus false diff --git a/bin/linkhandler b/bin/linkhandler new file mode 100755 index 0000000..7c7e96f --- /dev/null +++ b/bin/linkhandler @@ -0,0 +1,22 @@ +#!/bin/sh + +# Feed script a url or file location. +# If an image, it will view in sxiv, +# if a video or gif, it will view in mpv +# if a music file or pdf, it will download, +# otherwise it opens link in browser. + +# If no url given. Opens browser. For using script as $BROWSER. +[ -z "$1" ] && { "$BROWSER"; exit; } + +case "$1" in + *mkv|*webm|*mp4|*youtube.com/watch*|*youtube.com/playlist*|*youtu.be*|*hooktube.com*|*bitchute.com*) + setsid -f mpv -quiet "$1" >/dev/null 2>&1 ;; + *png|*jpg|*jpe|*jpeg|*gif) + curl -sL "$1" > "/tmp/$(echo "$1" | sed "s/.*\///")" && sxiv -a "/tmp/$(echo "$1" | sed "s/.*\///")" >/dev/null 2>&1 & ;; + *mp3|*flac|*opus|*mp3?source*) + setsid -f tsp curl -LO "$1" >/dev/null 2>&1 ;; + *) + if [ -f "$1" ]; then "$TERMINAL" -e "$EDITOR" "$1" + else setsid -f "$BROWSER" "$1" >/dev/null 2>&1; fi ;; +esac diff --git a/bin/md2ghtml b/bin/md2ghtml new file mode 100755 index 0000000..4d2e97d --- /dev/null +++ b/bin/md2ghtml @@ -0,0 +1,2 @@ +mdfolder=$HOME/.config/markdown +pandoc --self-contained --template=$mdfolder/template/template.html -c $mdfolder/css/page.css -c $mdfolder/css/markdown.css -c $mdfolder/css/highlight.css -o "$2" "$1" diff --git a/bin/md2pdf b/bin/md2pdf new file mode 100755 index 0000000..0654593 --- /dev/null +++ b/bin/md2pdf @@ -0,0 +1,5 @@ +#!/bin/sh + +MDFILE="$1" + +[ -r $MDFILE -a -f $MDFILE ] && pandoc $MDFILE -t html -o ${MDFILE[@]/%md/pdf} || echo "what a freak" diff --git a/bin/scrot_copy b/bin/scrot_copy new file mode 100755 index 0000000..48a2fc1 --- /dev/null +++ b/bin/scrot_copy @@ -0,0 +1,5 @@ +#!/bin/sh + +scrot -s -o /tmp/screenshot.png +xclip -sel clip -i /tmp/screenshot.png -t "image/png" + diff --git a/bin/search b/bin/search new file mode 100755 index 0000000..bb3b3a0 --- /dev/null +++ b/bin/search @@ -0,0 +1,23 @@ +#!/bin/bash + +QUERY=$@ + +if [[ -z $QUERY ]]; then + QUERY=$(dmenu -p "Search Query: " < /dev/null ) +fi + +[[ -n $QUERY ]] || exit + +QUERY=$(echo $QUERY | sed 's/ /+/g') + +RESULT=$(curl "http://s.herisson.ovh/search?q=$QUERY&format=json") + +TITLES=$(echo "$RESULT" | jq -r '.results[] | .title') +LINKS=$(echo "$RESULT" | jq -r '.results[] | .url') + +SELECT=$(paste -d ": " <(seq $(echo "$TITLES" | wc -l)) <(echo "$TITLES") <(echo "$LINKS")| dmenu -l 15 | cut -d: -f1) + +[[ -n $SELECT ]] || exit + +echo "$LINKS" | head -n $SELECT | tail -1 | xclip -sel clip + diff --git a/bin/search_open b/bin/search_open new file mode 100755 index 0000000..353fd2c --- /dev/null +++ b/bin/search_open @@ -0,0 +1,22 @@ +#!/bin/bash + +QUERY=$@ + +if [[ -z $QUERY ]]; then + QUERY=$(dmenu -p "Search Query: " < /dev/null ) +fi + +[[ -n $QUERY ]] || exit + +QUERY=$(echo $QUERY | sed 's/ /+/g') + +RESULT=$(curl "http://s.herisson.ovh/search?q=$QUERY&format=json") + +TITLES=$(echo "$RESULT" | jq -r '.results[] | .title') +LINKS=$(echo "$RESULT" | jq -r '.results[] | .url') + +SELECT=$(paste -d ": " <(seq $(echo "$TITLES" | wc -l)) <(echo "$TITLES") <(echo "$LINKS")| dmenu -l 15 | cut -d: -f1) + +[[ -n $SELECT ]] || exit + +echo "$LINKS" | head -n $SELECT | tail -1 | xargs xdg-open diff --git a/bin/switchkblayout b/bin/switchkblayout new file mode 100755 index 0000000..c71f1cc --- /dev/null +++ b/bin/switchkblayout @@ -0,0 +1,14 @@ +#!/usr/bin/env bash + +key=`setxkbmap -query | grep layout | awk '{print $2}'` + +if [[ $key == "fr" ]]; then + setxkbmap us +elif [[ $key == "us" ]]; then + setxkbmap dvorak +else + setxkbmap fr +fi +key=`setxkbmap -query | grep layout | awk '{print $2}'` +notify-send "Keyboard Layout: $key" + diff --git a/bin/tordone b/bin/tordone new file mode 100755 index 0000000..d81c3b7 --- /dev/null +++ b/bin/tordone @@ -0,0 +1,3 @@ +#!/bin/sh + +notify-send "✔ Transmission-daemon" "$TR_TORRENT_NAME has completely downloaded." diff --git a/bin/transadd b/bin/transadd new file mode 100755 index 0000000..c76a50d --- /dev/null +++ b/bin/transadd @@ -0,0 +1,6 @@ +#!/bin/sh + +pgrep -x transmission-da >/dev/null || (transmission-daemon && notify-send "Starting transmission daemon...") && sleep 3 + +# ssh 192.168.1.100 "transmission-remote -a \"$@\"" && notify-send "🔻 Transmission-daemon" "Torrent Added." +transmission-remote -a "$@" && notify-send "🔻 Transmission-daemon" "Torrent Added." diff --git a/bin/wacom-to-first-screen.sh b/bin/wacom-to-first-screen.sh new file mode 100755 index 0000000..227260d --- /dev/null +++ b/bin/wacom-to-first-screen.sh @@ -0,0 +1,5 @@ +Display="DVI-D-0" #find it with xrandr + +Stylusid=$(xinput | grep -Po 'Wacom (.*)' | grep -Po 'id=(\d*)' | grep -Po '\d*') + +$(echo $Stylusid | tr ' ' '\n' | xargs -i xinput map-to-output {} $Display) diff --git a/bin/windowgrabber b/bin/windowgrabber new file mode 100755 index 0000000..c113195 --- /dev/null +++ b/bin/windowgrabber @@ -0,0 +1,43 @@ +#!/bin/bash +# Originally by https://github.com/windelicato/ +# edited beyound recognition + +follower() { +if [ "$(pgrep -cx windowgrabber)" = 1 ] ; then + bspc config pointer_follows_focus false +fi +} + +trap 'follower' INT TERM QUIT EXIT + +size=${2:-'20'} +dir=$1 + +bspc config pointer_follows_focus true +# Find current window mode +is_floating() { +bspc query -T -n | grep -q '"state":"floating"' +} +# If the window is floating, move it +if is_floating; then +#only parse input if window is floating,tiled windows accept input as is + case "$dir" in + west) switch="-x" + sign="-" + ;; + east) switch="-x" + sign="+" + ;; + north) switch="-y" + sign="-" + ;; + *) switch="-y" + sign="+" + ;; + esac + xdo move ${switch} ${sign}${size} + +# Otherwise, window is tiled: switch with window in given direction +else + bspc node -n ${dir}.!automatic || bspc node -s ${dir} || bspc node -m ${dir} && bspc monitor -f +fi diff --git a/bin/windowpromoter b/bin/windowpromoter new file mode 100755 index 0000000..1a23dfb --- /dev/null +++ b/bin/windowpromoter @@ -0,0 +1,26 @@ +#!/usr/bin/sh + +receptacle=$(bspc query -N -n ".leaf.!window.local" | awk NR==1) + +window_promotion() +{ + if [ -n "$receptacle" ] > /dev/null ; then + bspc node -n "$receptacle" + elif [ -z "$(bspc query -N -n last.!automatic.local)" ]; then \ + bspc node -s biggest.!focused.local; \ + else \ + bspc node -n last.!automatic.local; \ + fi +} + +if bspc query -N -n "@/.!automatic" > /dev/null ; then + bspc node -n @/ || window_promotion + else + if [ -n "$receptacle" ] > /dev/null ; then + bspc node -n "$receptacle" + elif [ -z "$(bspc query -N -n last.!automatic.local)" ]; then \ + bspc node -s biggest.!focused.local; \ + else \ + bspc node -n last.!automatic.local; \ + fi +fi diff --git a/bin/workspaces_multimonitor b/bin/workspaces_multimonitor new file mode 100755 index 0000000..4db6546 --- /dev/null +++ b/bin/workspaces_multimonitor @@ -0,0 +1,51 @@ +#!/bin/bash +#all_monitors=$(xrandr -q | awk '/connected/ {print $1}') +#default_screen=$(xrandr | awk '/ connected/ {print $1;exit;}') +#extra_monitors=$(xrandr -q | awk '/connected/ {print $1}' | grep -v $default_screen) + +##First, configure stuff with xrandr +#[[ $(who) != "" ]] && USER=$(who | grep :0\) | cut -f 1 -d ' ') || \ +#USER=$(echo /home/* | cut -f 3 -d '/') + +#export DISPLAY=:0.0 +#export XAUTHORITY=/home/$USER/.Xauthority + +#for monitor in $extra_monitors; do +# prev_mon=$(xrandr | awk '/connected/ {print $1}' | grep -B1 "^$monitor" | grep -vE "^$monitor|^--$") +# xrandr --output $monitor \ +# --auto \ +# --right-of $prev_mon +#done + +##Then, create workspaces on all monitors + I=1 + M=$(bspc query -M | wc -l) + if [[ "$M" == 1 ]]; then + bspc monitor -d I II III IV V VI VII VIII IX X + elif [[ "$M" == 2 ]]; then + bspc monitor $(bspc query -M | awk NR==1) -d I II III IV V + bspc monitor $(bspc query -M | awk NR==2) -d VI VII VIII IX X + elif [[ "$M" == 3 ]]; then + bspc monitor $(bspc query -M | awk NR==1) -d I II III IV + bspc monitor $(bspc query -M | awk NR==2) -d V VI VII + bspc monitor $(bspc query -M | awk NR==3) -d VIII IX X + elif [[ "$M" == 4 ]]; then + bspc monitor $(bspc query -M | awk NR==1) -d I II III + bspc monitor $(bspc query -M | awk NR==2) -d IV V VI + bspc monitor $(bspc query -M | awk NR==3) -d VII VIII + bspc monitor $(bspc query -M | awk NR==4) -d IX X + elif [[ "$M" == 5 ]]; then + bspc monitor $(bspc query -M | awk NR==1) -d I II + bspc monitor $(bspc query -M | awk NR==2) -d III IV + bspc monitor $(bspc query -M | awk NR==3) -d V VI + bspc monitor $(bspc query -M | awk NR==4) -d VII VIII + bspc monitor $(bspc query -M | awk NR==5) -d IX X + else + for monitor in $(bspc query -M); do + bspc monitor $monitor \ + -n "$I" \ + -d $I/{a,b,c} + let I++ + done + fi +