From b546276ae0b88ebfd109c4e98e7f7b96de471552 Mon Sep 17 00:00:00 2001 From: DustVoice Date: Thu, 3 Sep 2020 18:07:02 +0200 Subject: [PATCH] Add bspwm workspace saving functionality to dmenu and zsh --- .config/dmenu/dmenu_bspwm_desktop | 6 +- .config/sxhkd/sxhkdrc | 6 ++ .ssh/known_hosts | 1 + .xinitrc | 10 +++- .zsh_alias | 93 +++++++++++++++++++++++++++---- .zshenv | 2 + 6 files changed, 104 insertions(+), 14 deletions(-) diff --git a/.config/dmenu/dmenu_bspwm_desktop b/.config/dmenu/dmenu_bspwm_desktop index 90bcec3..e439913 100755 --- a/.config/dmenu/dmenu_bspwm_desktop +++ b/.config/dmenu/dmenu_bspwm_desktop @@ -22,7 +22,7 @@ local desktop="" if [[ $1 == "delete" || $1 == "rename" ]]; then desktop=$(echo "" | dmenu -i -fn $(get-font) -nb "#282a36" -nf "#f8f8f2" -sb "#44475a" -sf "#f8f8f2" -p "$dmenu_string") else - if [[ $1 != "bubbleprev" && $1 != "bubblenext" ]]; then + if [[ $1 != "bubbleprev" && $1 != "bubblenext" && $1 != "save" && $1 != "load" ]]; then desktop=$(bspc query -m focused -D --names | dmenu -i -fn $(get-font) -nb "#282a36" -nf "#f8f8f2" -sb "#44475a" -sf "#f8f8f2" -p "$dmenu_string") fi fi @@ -49,4 +49,8 @@ case $1 in bspc desktop -b prev ;; "bubblenext") bspc desktop -b next ;; + "save") + bspwm-save ;; + "load") + bspwm-load ;; esac diff --git a/.config/sxhkd/sxhkdrc b/.config/sxhkd/sxhkdrc index 73a2245..453ccc4 100644 --- a/.config/sxhkd/sxhkdrc +++ b/.config/sxhkd/sxhkdrc @@ -149,6 +149,12 @@ alt + z; h alt + z; l $HOME/.config/dmenu/dmenu_bspwm_desktop bubblenext +alt + z; y + $HOME/.config/dmenu/dmenu_bspwm_desktop save + +alt + z; p + $HOME/.config/dmenu/dmenu_bspwm_desktop load + alt + a; g $HOME/.config/dmenu/dmenu_bspwm_monitor goto diff --git a/.ssh/known_hosts b/.ssh/known_hosts index 73c9846..e40c79b 100644 --- a/.ssh/known_hosts +++ b/.ssh/known_hosts @@ -7,3 +7,4 @@ ssh.strato.de,81.169.145.126 ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTY aur.archlinux.org,95.216.144.15 ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBLMiLrP8pVi5BFX2i3vepSUnpedeiewE5XptnUnau+ZoeUOPkpoCgZZuYfpaIQfhhJJI5qgnjJmr4hyJbe/zxow= 2a01:4f9:c010:50::1 ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBLMiLrP8pVi5BFX2i3vepSUnpedeiewE5XptnUnau+ZoeUOPkpoCgZZuYfpaIQfhhJJI5qgnjJmr4hyJbe/zxow= 140.82.121.3 ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAq2A7hRGmdnm9tUDbO9IDSwBK6TbQa+PXYPCPy6rbTrTtw7PHkccKrpp0yVhp5HdEIcKr6pLlVDBfOLX9QUsyCOV0wzfjIJNlGEYsdlLJizHhbn2mUjvSAHQqZETYP81eFzLQNnPHt4EVVUh7VfDESU84KezmD5QlWpXLmvU31/yMf+Se8xhHTvKSCZIFImWwoG6mbUoWf9nzpIoaSjB+weqqUUmpaaasXVal72J+UX2B+2RPW3RcT0eOzQgqlJL3RKrTJvdsjE3JEAvGq3lGHSZXy28G3skua2SmVi/w4yCE6gbODqnTWlg7+wC604ydGXA8VJiS5ap43JXiUFFAaQ== +140.82.121.4 ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAq2A7hRGmdnm9tUDbO9IDSwBK6TbQa+PXYPCPy6rbTrTtw7PHkccKrpp0yVhp5HdEIcKr6pLlVDBfOLX9QUsyCOV0wzfjIJNlGEYsdlLJizHhbn2mUjvSAHQqZETYP81eFzLQNnPHt4EVVUh7VfDESU84KezmD5QlWpXLmvU31/yMf+Se8xhHTvKSCZIFImWwoG6mbUoWf9nzpIoaSjB+weqqUUmpaaasXVal72J+UX2B+2RPW3RcT0eOzQgqlJL3RKrTJvdsjE3JEAvGq3lGHSZXy28G3skua2SmVi/w4yCE6gbODqnTWlg7+wC604ydGXA8VJiS5ap43JXiUFFAaQ== diff --git a/.xinitrc b/.xinitrc index c7d023f..6814563 100644 --- a/.xinitrc +++ b/.xinitrc @@ -29,10 +29,14 @@ if [ -d /etc/X11/xinit/xinitrc.d ] ; then fi setxkbmap "us,us" ",intl" "grp:shifts_toggle" -xset m 0 0 +xset m 1 1 xsetroot -cursor_name left_ptr export _JAVA_AWT_WM_NONPARENTING=1 -mkdir -p $HOME/.local/share/bspwm -exec bspwm >$HOME/.local/share/bspwm/output.log 2>$HOME/.local/share/bspwm/error.log +if [ -n $BSPWM_FILES ]; then + mkdir -p $BSPWM_FILES + exec bspwm >$BSPWM_FILES/output.log 2>$BSPWM_FILES/error.log +else + exec bspwm +fi diff --git a/.zsh_alias b/.zsh_alias index 93c5d7b..4352170 100644 --- a/.zsh_alias +++ b/.zsh_alias @@ -1,19 +1,67 @@ +# === +# Directory listing +# === alias la='ls -lahF' alias ll='ls -lhF' alias ls='ls -F --color=tty' alias lsa='ls -aF' +# === +# Software +# === + +# ====== +# Keyboard layout +# ====== alias layout='xkblayout-state print "%s(%v)" && echo -n "\n"' +# ====== +# ====== +# Compositing +# ====== alias picom-default='picom -bGC --backend glx --unredir-if-possible-delay 1000 --vsync' +# ====== +# ====== +# Octave +# ====== +alias octave-gui='octave --force-gui' +# ====== + +# ====== +# Polkit +# ====== +alias xfce-polkit='/usr/lib/xfce-polkit/xfce-polkit' +# ====== + +# ====== +# Resolve +# ====== +alias davinci-resolve='/opt/resolve/bin/resolve' +# ====== + +# ====== +# Tmate +# ====== +alias tmate-obs='tmate -k tmk-ET35fx5m9cA7cxOt4jjWkSmaOy -r DustVoice' +# ====== + +# ====== +# Screenkey +# ====== function screenkey-obs-func() { width=$(xrandr | awk '$0 ~ "*" {split($1,res,"x"); print res[1];}') height=$(xrandr | awk '$0 ~ "*" {split($1,res,"x"); print res[2];}') screenkey --no-systray -t 2 -p fixed -s small -g $(awk -v height=$height -v width=$width 'BEGIN {printf "%.0fx%.0f+%.0f+%.0f", (width * 0.5), (height * 0.06), (width * 0.25), (height * 0.02)}') --key-mode composed --bak-mode full --mods-mode normal -f Hack --font-color "#f8f8f2" --bg-color "#44475a" --opacity "1.0" } -alias screenkey-obs='screenkey-obs-func' +alias screenkey-obs='screenkey-obs-func' +# ====== +# === + +# === +# Font +# === function get-font-func() { fallback_font="Hack:size=10:antialias=true:autohint=true" font="" @@ -25,15 +73,40 @@ function get-font-func() { echo "$font" } alias get-font='get-font-func' +# === -alias tmate-obs='tmate -k tmk-ET35fx5m9cA7cxOt4jjWkSmaOy -r DustVoice' - -alias xfce-polkit='/usr/lib/xfce-polkit/xfce-polkit' - -alias davinci-resolve='/opt/resolve/bin/resolve' - -alias rofi-scripts='alias | sed -e "s/=.*//"' - +# === +# Lockscreen +# === alias lock-screen='xset 600 60 && env XSECURELOCK_AUTH_BACKGROUND_COLOR=rgb:28/2a/36 XSECURELOCK_AUTH_FOREGROUND_COLOR=rgb:f8/f8/f2 XSECURELOCK_AUTH_TIMEOUT=10 XSECURELOCK_BLANK_TIMEOUT=-1 XSECURELOCK_BLANK_DPMS_STATE=on XSECURELOCK_DISCARD_FIRST_KEYPRESS=1 XSECURELOCK_PASSWORD_PROMPT=cursor XSECURELOCK_SHOW_DATETIME=1 XSECURELOCK_SHOW_HOSTNAME=1 XSECURELOCK_SHOW_USERNAME=1 xsecurelock &' +# === -alias octave-gui='octave --force-gui' +# === +# bspwm +# === +function bspwm-workspaces-init-func() { + if [[ ! -n $BSPWM_FILES ]]; then + export BSPWM_FILES="$HOME/.local/share/bspwm" + fi + mkdir -p $BSPWM_FILES +} + +function bspwm-save-func() { + bspwm-workspaces-init-func + if [[ -f $BSPWM_FILES/$1 ]]; then + cp $BSPWM_FILES/$1 $BSPWM_FILES/$2 + fi + bspc query -m focused -D --names | tr '\n' ' ' | sed 's/ $//g' > $BSPWM_FILES/$1 +} + +function bspwm-load-func() { + bspwm-workspaces-init-func + if [[ -f $BSPWM_FILES/$1 ]]; then + bspwm-save-func $2 $2 + bspc monitor -d $(< $BSPWM_FILES/$1) + fi +} + +alias bspwm-save="bspwm-save-func workspaces workspaces.prev_save" +alias bspwm-load="bspwm-load-func workspaces workspaces.prev_load" +# === diff --git a/.zshenv b/.zshenv index 98ce450..d617399 100644 --- a/.zshenv +++ b/.zshenv @@ -48,6 +48,8 @@ export XDG_CONFIG_HOME="$HOME/.config" export WINIT_X11_SCALE_FACTOR=1 +export BSPWM_FILES="$HOME/.local/share/bspwm" + if [[ -f $HOME/.zsh_alias ]]; then source $HOME/.zsh_alias fi