aboutsummaryrefslogtreecommitdiff
path: root/.local/share
diff options
context:
space:
mode:
Diffstat (limited to '.local/share')
-rwxr-xr-x.local/share/bin/bgcol6
-rwxr-xr-x.local/share/bin/fork2
-rwxr-xr-x.local/share/bin/mode73
3 files changed, 40 insertions, 41 deletions
diff --git a/.local/share/bin/bgcol b/.local/share/bin/bgcol
index 90b4a04..8b7111f 100755
--- a/.local/share/bin/bgcol
+++ b/.local/share/bin/bgcol
@@ -1,2 +1,6 @@
#!/bin/sh
-convert -size 1x1 xc:$1 /tmp/bgcol.png && feh --bg-tile /tmp/bgcol.png && rm /tmp/bgcol.png
+COLOR="$1"
+[ -z "$COLOR" ] && COLOR="$(xrdb -get background)"
+convert -size 1x1 "xc:$COLOR" /tmp/bgcol.png
+feh --bg-tile /tmp/bgcol.png
+rm /tmp/bgcol.png
diff --git a/.local/share/bin/fork b/.local/share/bin/fork
index cd7e68a..63e7541 100755
--- a/.local/share/bin/fork
+++ b/.local/share/bin/fork
@@ -1,2 +1,2 @@
#!/bin/sh
-"$@" &> /dev/null & disown
+(setsid "$@" > /dev/null 2> /dev/null &)
diff --git a/.local/share/bin/mode b/.local/share/bin/mode
index c4944a5..5e49f82 100755
--- a/.local/share/bin/mode
+++ b/.local/share/bin/mode
@@ -1,26 +1,25 @@
#!/bin/sh
-
MODE="$1"
get_color() {
- xrdb -query | grep $1 | head -n1 | cut -f2
+ xrdb -get "$1"
}
hex_to_rgb_array() {
- printf "%d\n%d\n%d\n" "0x${1:1:2}" "0x${1:3:2}" "0x${1:5:2}" | jq -jc --slurp '.'
+ printf "%d\n%d\n%d\n" "0x$(echo "$1" | cut -c2-3)" "0x$(echo "$1" | cut -c4-5)" "0x$(echo "$1" | cut -c6-7)" | jq -jc --slurp '.'
}
get_color_rgb_array() {
- hex_to_rgb_array "`get_color $1`"
+ hex_to_rgb_array "$(get_color "$1")"
}
mix_rgb() {
- R1="`printf "%d" "0x${1:1:2}"`"
- G1="`printf "%d" "0x${1:3:2}"`"
- B1="`printf "%d" "0x${1:5:2}"`"
- R2="`printf "%d" "0x${2:1:2}"`"
- G2="`printf "%d" "0x${2:3:2}"`"
- B2="`printf "%d" "0x${2:5:2}"`"
+ R1="$(printf "%d" "0x$(echo "$1" | cut -c2-3)")"
+ G1="$(printf "%d" "0x$(echo "$1" | cut -c4-5)")"
+ B1="$(printf "%d" "0x$(echo "$1" | cut -c6-7)")"
+ R2="$(printf "%d" "0x$(echo "$2" | cut -c2-3)")"
+ G2="$(printf "%d" "0x$(echo "$2" | cut -c4-5)")"
+ B2="$(printf "%d" "0x$(echo "$2" | cut -c6-7)")"
printf "#"
dc -e"$R1 $3 * $R2 1 $3 - * + 1 / p" | xargs printf "%02x"
@@ -33,7 +32,7 @@ switch_xrdb() {
}
switch_dunst() {
- read -r -d '' conf << EOF
+ cat "$XDG_CONFIG_HOME/dunst/base" - << EOF > "$XDG_CONFIG_HOME/dunst/dunstrc"
frame_color = "$(get_color color1)"
[urgency_low]
@@ -52,11 +51,10 @@ foreground = "$(get_color background)"
frame_color = "$(get_color color1)"
timeout = 0
EOF
- echo "$conf" | cat "$XDG_CONFIG_HOME/dunst/base" - > "$XDG_CONFIG_HOME/dunst/dunstrc"
}
switch_zathura() {
- read -r -d '' conf << EOF
+ cat << EOF > "$XDG_CONFIG_HOME/zathura/colors"
set default-bg "$(get_color background)"
set statusbar-bg "$(get_color background)"
set inputbar-bg "$(get_color background)"
@@ -81,12 +79,11 @@ set highlight-color "$(get_color color9)"
set highlight-active-color "$(get_color color13)"
set notification-bg "$(get_color color13)"
EOF
- echo "$conf" > "$XDG_CONFIG_HOME/zathura/colors"
}
switch_gtk() {
GTK_3_SETTINGS_INI="$XDG_CONFIG_HOME/gtk-3.0/settings.ini"
- if [ $1 == "light" ]; then
+ if [ $1 = "light" ]; then
sed "s/-Dark/-Light/" -i "$GTK_3_SETTINGS_INI"
sed "s/gtk-application-prefer-dark-theme.*/gtk-application-prefer-dark-theme=false/" -i "$GTK_3_SETTINGS_INI"
else
@@ -98,7 +95,7 @@ switch_gtk() {
switch_fcitx5() {
accent="$(get_color color9)"
- read -r -d '' conf << EOF
+ cat "$XDG_DATA_HOME/fcitx5/themes/loek/base.conf" - << EOF > "$XDG_DATA_HOME/fcitx5/themes/loek/theme.conf"
[InputPanel]
NormalColor=$(get_color foreground)
HighlightCandidateColor=$(get_color background)
@@ -124,11 +121,10 @@ Color=${accent}
[Menu/Separator]
Color=$(get_color color7)
EOF
- echo "$conf" | cat "$XDG_DATA_HOME/fcitx5/themes/loek/base.conf" - > "$XDG_DATA_HOME/fcitx5/themes/loek/theme.conf"
}
switch_startpage() {
- read -r -d '' conf << EOF
+ cat << EOF > "$XDG_CONFIG_HOME/startpage/colors.css"
/* AUTOMATICALLY GENERATED, DO NOT EDIT */
:root {
@@ -152,20 +148,19 @@ switch_startpage() {
--color15: $(get_color color15);
}
EOF
- echo "$conf" > "$XDG_CONFIG_HOME/startpage/colors.css"
}
switch_chrome() {
cd ~/.cache/wal/chromium
rm -f 'Cached Theme.pak' 'bg.png' 'manifest.json'
- convert -size 100x100 "xc:`get_color background`" bg.png
+ convert -size 100x100 "xc:$(get_color background)" bg.png
BG_ALT=$(mix_rgb $(get_color color7) $(get_color background) '0.20')
FG_ALT=$(mix_rgb $(get_color color15) $(get_color foreground) '0.60')
jq -nc \
- --argjson bg "`get_color_rgb_array background`" \
- --argjson bg_alt "`hex_to_rgb_array $BG_ALT`" \
- --argjson fg "`get_color_rgb_array foreground`" \
- --argjson fg_alt "`hex_to_rgb_array $FG_ALT`" \
+ --argjson bg "$(get_color_rgb_array background)" \
+ --argjson bg_alt "$(hex_to_rgb_array $BG_ALT)" \
+ --argjson fg "$(get_color_rgb_array foreground)" \
+ --argjson fg_alt "$(hex_to_rgb_array $FG_ALT)" \
'{
"description": "colorscheme generated by mode",
"manifest_version": 2,
@@ -198,7 +193,7 @@ switch_chrome() {
}
switch_polybar() {
- read -r -d '' conf << EOF
+ cat << EOF > "$XDG_CONFIG_HOME/polybar/colors.ini"
[color]
bg = \${xrdb:background:$(get_color background)}
fg = \${xrdb:foreground:$(get_color foreground)}
@@ -209,11 +204,10 @@ alpha = #00000000
; vim:ft=dosini
EOF
- echo "$conf" > "$XDG_CONFIG_HOME/polybar/colors.ini"
}
switch_vim_lightline() {
- read -r -d '' conf << EOF
+ cat - "$XDG_CONFIG_HOME/nvim/lightline-base.vim" << EOF > "$XDG_CONFIG_HOME/nvim/lightline.vim"
let s:bg = [ '$(get_color background)', 'NONE' ]
let s:fg = [ '$(get_color foreground)', 'NONE' ]
let s:mode = [ '$(get_color color0)', 'NONE' ]
@@ -221,11 +215,10 @@ let s:faint = [ '$(get_color color8)', 'NONE' ]
let s:none = [ 'NONE', 'NONE' ]
let s:test = [ '#ff00ff', 'NONE' ]
EOF
- echo "$conf" | cat - "$XDG_CONFIG_HOME/nvim/lightline-base.vim" > "$XDG_CONFIG_HOME/nvim/lightline.vim"
}
switch_discord() {
- read -r -d '' conf << EOF
+ cat << EOF > "$XDG_CONFIG_HOME/BetterDiscord/themes/mode.theme.css"
/**
* @name mode
* @author mode
@@ -254,11 +247,10 @@ switch_discord() {
--background-tertiary: $(get_color background);
}
EOF
- echo "$conf" > "$XDG_CONFIG_HOME/BetterDiscord/themes/mode.theme.css"
}
reload_terms() {
- read -r -d '' escape_msgs << EOF
+ escape_msgs="$(cat << EOF | tr -d '\n'
\033]11;$(get_color background)\007
\033]10;$(get_color foreground)\007
\033]12;$(get_color foreground)\007
@@ -283,31 +275,33 @@ reload_terms() {
\033]4;14;$(get_color color14)\007
\033]4;15;$(get_color color15)\007
EOF
- escape_msgs=$(printf "$escape_msgs" | tr -d '\n')
+)"
find /dev/pts -exec sh -c "printf \"$escape_msgs\" > {}" \; 2> /dev/null
}
reload_dunst() {
killall dunst
- dunst &> /dev/null & disown
+ fork dunst
}
reload_polybar() {
- polybar-msg cmd restart &> /dev/null
+ fork polybar-msg cmd restart
}
reload_fcitx5() {
- fcitx5 -rd &> /dev/null & disown
+ fork fcitx5 -rd
}
reload_gtk() {
# this is max jank but xfsettingsd does other things besides live gtk theme
# reloading, and i don't like having it running constantly because it fucks
# up fcitx5 and xbindkeys
- xfsettingsd &> /dev/null &
- PID=$!
- sleep 1
- kill $PID
+ (
+ xfsettingsd &
+ PID=$!
+ sleep 1
+ kill $PID
+ )
}
switch_cfgs() {
@@ -338,6 +332,7 @@ reload_apps() {
reload_polybar
reload_dunst
+ return
reload_terms
reload_fcitx5
reload_gtk