i3-resurrect etc.

This commit is contained in:
Harri Lahtinen 2019-10-31 18:02:07 +02:00
parent ce8a4809b1
commit 3648f00fb5
7 changed files with 170 additions and 23 deletions

60
.config/Scripts/bluetoothctl.sh Executable file
View File

@ -0,0 +1,60 @@
#!/bin/sh
bluetooth_print() {
bluetoothctl | while read -r; do
if [ "$(systemctl is-active "bluetooth.service")" = "active" ]; then
printf '#1'
devices_paired=$(bluetoothctl paired-devices | grep Device | cut -d ' ' -f 2)
counter=0
echo "$devices_paired" | while read -r line; do
device_info=$(bluetoothctl info "$line")
if echo "$device_info" | grep -q "Connected: yes"; then
device_alias=$(echo "$device_info" | grep "Alias" | cut -d ' ' -f 2-)
if [ $counter -gt 0 ]; then
printf ", %s" "$device_alias"
else
printf " %s" "$device_alias"
fi
counter=$((counter + 1))
fi
printf '\n'
done
else
echo "#2"
fi
done
}
bluetooth_toggle() {
if bluetoothctl show | grep -q "Powered: no"; then
bluetoothctl power on >> /dev/null
sleep 1
devices_paired=$(bluetoothctl paired-devices | grep Device | cut -d ' ' -f 2)
echo "$devices_paired" | while read -r line; do
bluetoothctl connect "$line" >> /dev/null
done
else
devices_paired=$(bluetoothctl paired-devices | grep Device | cut -d ' ' -f 2)
echo "$devices_paired" | while read -r line; do
bluetoothctl disconnect "$line" >> /dev/null
done
bluetoothctl power off >> /dev/null
fi
}
case "$1" in
--toggle)
bluetooth_toggle
;;
*)
bluetooth_print
;;
esac

View File

@ -0,0 +1,25 @@
#!/usr/bin/env bash
set -euo pipefail
IFS=$'\n\t'
# i3-resurrect-restore-all]
# restoring all available saved workspaces
# arguments: No arguments. Assumes .i3 it places at ~/
# expected input/output - sample input -> output ( a few lines)
# example suggested usage: myscript filename > bigoutputfile
#save current workspace
cur_workspace=$(i3-msg -t get_workspaces | jq -r '.[] | select(.visible == true) | .name')
# extract workspace name which is defined between two underscored
workspaces=$(ls -l ~/.i3/i3-resurrect/*.json | grep -Po '.*_\K(.*)_' | sed 's/_//' | uniq)
echo "Found workspaces: $workspaces"
# restore workspaces
for ws in ${workspaces[*]}; do
echo "restoring $ws"
i3-resurrect restore -w $ws
done
notify-send "i3-resurrect" "Restored all workspaces"
i3-msg workspace $cur_workspace

View File

@ -0,0 +1,27 @@
#!/usr/bin/env bash
set -euo pipefail
IFS=$'\n\t'
# i3-resurrect-save-all
# this program saves all currently active workspaces with i3-resurrect -
# arguments: take no arguments and assumes .i3/i3-resurrect is at "~/"
# expected output: showin what workspace is currently being saved and sends a notification when done
# example suggested usage: i3-resurrect-save-all
# remove old saves
rm -f ~/.i3/i3-resurrect/*
# find running workspaces
workspaces=$(i3-msg -t get_workspaces | jq '.[] | .name')
echo "Found workspaces: $workspaces"
# Save workspaces with programs running
for ws in ${workspaces[*]}; do
# remove quotes from output
temp="${ws%\"}"
temp="${temp#\"}"
echo "saving $temp"
i3-resurrect save -w $temp
done
notify-send "i3-resurrect" "Saved all workspaces"

View File

@ -238,7 +238,8 @@ unredir-if-possible = true;
# get rid of the screen tearing in full screen Chrome
unredir-if-possible-exclude = [
"name *= 'Chrome'"
"name *= 'Chrome'",
"name *= 'Chromium'"
];
# Specify a list of conditions of windows that should always be considered focused.

View File

@ -51,11 +51,11 @@ bindsym $mod+Shift+c sticky toggle
######### COLORS ##########
# BORDER BACKGROUND TEXT INDICATOR CHILD_BORDER
client.focused #636E90 #9797B2 #020203 #636E90 #778AAD
client.unfocused #778AAD #636E90 #e2cedb #778AAD #020203
client.focused_inactive #020203 #9e9099 #e2cedb #778AAD #020203
client.urgent #8C7281 #8C7281 #020203 #8C7281 #8C7281
client.background #9e9099
client.focused #494C53 #6B6D73 #03060D #494C53 #5E6168
client.unfocused #5E6168 #494C53 #bfc0c2 #5E6168 #03060D
client.focused_inactive #03060D #858687 #bfc0c2 #5E6168 #03060D
client.urgent #595C63 #595C63 #03060D #595C63 #595C63
client.background #858687
###---Starting External Scripts---###
@ -127,6 +127,10 @@ bindsym $mod+Shift+b move scratchpad
# Show the first scratchpad window
bindsym $mod+Shift+e scratchpad show
# i3-resurrect save/restore
bindsym Mod1+Shift+s exec ~/.config/Scripts/i3-resurrect-save-all
bindsym Mod1+Shift+r exec ~/.config/Scripts/i3-resurrect-restore-all
#Composite manager:
bindsym $mod+b exec --no-startup-id pkill compton
bindsym $mod+Ctrl+b exec --no-startup-id compton -b -f
@ -193,7 +197,7 @@ bindsym $mod+s gaps inner current plus 5
bindsym $mod+Shift+s gaps inner current minus 5
#bindsym $mod+d exec rofi -config ~/.config/rofi/config -show drun
bindsym $mod+d exec dmenu_run -fn 'Ubuntu Mono derivative Powerline-18' -h '35' -nb '#E1A0BA' -sf '#020203' -sb '#8C7281' -nf '#e2cedb'
bindsym $mod+d exec dmenu_run -fn 'Ubuntu Mono derivative Powerline-18' -h '35' -nb '#7A7C82' -sf '#03060D' -sb '#595C63' -nf '#bfc0c2'
bindsym Mod1+d exec ~/.config/Scripts/rofi-bangs.sh
bindsym $mod+Shift+d gaps inner current set 0; gaps outer current set 0

View File

@ -5,21 +5,21 @@
;
[colors]
background = #00000000
background-alt = #636E90
foreground = #778AAD
foreground-alt = #9FA7CA
highlight = #e2cedb
error = #8C7281
red = #8C7281
yellow = #9797B2
green = #E1A0BA
darkblue = #778AAD
background-alt = #494C53
foreground = #5E6168
foreground-alt = #7E8187
highlight = #bfc0c2
error = #595C63
red = #595C63
yellow = #6B6D73
green = #7A7C82
darkblue = #5E6168
alert = #FF0000
lightblue = #e2cedb
orange = #9FA7CA
blue = #636E90
black = #020203
grey = #9e9099
lightblue = #bfc0c2
orange = #7E8187
blue = #494C53
black = #03060D
grey = #858687
[bar/top]
monitor = ${env:MONITOR:eDP-1}
@ -38,7 +38,7 @@ monitor = ${env:MONITOR:eDP-1}
include-file = ~/.config/polybar/bottom-bar
modules-left = hostname arrowb01
modules-center = cpu memory temperature filesystem
modules-right = arrowb1 openweather
modules-right = arrowb2 bluetoothctl arrowb1 openweather
[module/arrowb01]
type = custom/text
@ -50,6 +50,12 @@ content-background = #00000000
type = custom/text
content = ""
content-foreground = ${colors.green}
content-background = ${colors.orange}
[module/arrowb2]
type = custom/text
content = ""
content-foreground = ${colors.orange}
content-background = #00000000
[module/arrow01]
@ -119,6 +125,15 @@ content = ""
content-foreground = ${colors.darkblue}
content-background = #00000000
[module/bluetoothctl]
type = custom/script
exec = ~/.config/Scripts/bluetoothctl.sh
tail = true
click-left = ~/.config/Scripts/bluetoothctl.sh --toggle
label = " %output% "
label-foreground = ${colors.black}
label-background = ${colors.orange}
[module/expressvpn-status]
type = custom/script
exec = ~/.config/Scripts/expressvpn-status.sh

View File

@ -38,7 +38,7 @@ monitor = ${{env:MONITOR:eDP-1}}
include-file = ~/.config/polybar/bottom-bar
modules-left = hostname arrowb01
modules-center = cpu memory temperature filesystem
modules-right = arrowb1 openweather
modules-right = arrowb2 bluetoothctl arrowb1 openweather
[module/arrowb01]
type = custom/text
@ -50,6 +50,12 @@ content-background = #00000000
type = custom/text
content = ""
content-foreground = ${{colors.green}}
content-background = ${{colors.orange}}
[module/arrowb2]
type = custom/text
content = ""
content-foreground = ${{colors.orange}}
content-background = #00000000
[module/arrow01]
@ -119,6 +125,15 @@ content = ""
content-foreground = ${{colors.darkblue}}
content-background = #00000000
[module/bluetoothctl]
type = custom/script
exec = ~/.config/Scripts/bluetoothctl.sh
tail = true
click-left = ~/.config/Scripts/bluetoothctl.sh --toggle
label = " %output% "
label-foreground = ${{colors.black}}
label-background = ${{colors.orange}}
[module/expressvpn-status]
type = custom/script
exec = ~/.config/Scripts/expressvpn-status.sh