From 2dc5ec7085e1c1bbc406f2089dddf8f6e1d9d206 Mon Sep 17 00:00:00 2001 From: lonkaars Date: Sat, 9 Mar 2024 00:04:46 +0100 Subject: more update (auto install betterdiscord) --- .config/mode/switch.d/chrome | 44 ------------------------------ .config/mode/switch.d/chromium | 45 +++++++++++++++++++++++++++++++ .local/share/applications/discord.desktop | 9 +++++++ .local/share/bin/decsync2plain | 2 +- .local/share/bin/discord | 3 +++ .local/share/bin/installbd | 28 +++++++++++++++++++ .local/share/bin/nodisconnect | 3 +++ .profile | 4 +++ 8 files changed, 93 insertions(+), 45 deletions(-) delete mode 100755 .config/mode/switch.d/chrome create mode 100755 .config/mode/switch.d/chromium create mode 100644 .local/share/applications/discord.desktop create mode 100755 .local/share/bin/discord create mode 100755 .local/share/bin/installbd diff --git a/.config/mode/switch.d/chrome b/.config/mode/switch.d/chrome deleted file mode 100755 index 4c596c3..0000000 --- a/.config/mode/switch.d/chrome +++ /dev/null @@ -1,44 +0,0 @@ -#!/bin/sh -( - cd ~/.cache/wal/chromium - rm -f 'Cached Theme.pak' 'bg.png' 'manifest.json' - convert -size 100x100 "xc:$bg" bg.png - bg_alt=$(mix_rgb $color7 $bg 0.20) - fg_alt=$(mix_rgb $color15 $fg 0.60) - bg="$(hex_to_rgb_array "$bg")" - fg="$(hex_to_rgb_array "$fg")" - bg_alt="$(hex_to_rgb_array "$bg_alt")" - fg_alt="$(hex_to_rgb_array "$fg_alt")" - cat << EOF > manifest.json -{ - "description": "colorscheme generated by mode", - "manifest_version": 2, - "name": "mode theme", - "theme": { - "images": { "theme_frame": "bg.png" }, - "colors": { - "frame": $bg, - "button_background": $fg, - "ntp_background": $bg, - "ntp_text": $bg, - "toolbar": $bg_alt, - "toolbar_button_icon": $fg, - "tab_background_text": $fg_alt, - "tab_background_text_inactive": $fg_alt, - "tab_background_text_incognito": $fg_alt, - "tab_background_text_incognito_inactive": $fg_alt, - "bookmark_text": $fg, - "tab_text": $fg - }, - "tints": { - "buttons": [ -1, -1, -1 ], - "frame_inactive": [ -1, -1, -1 ], - "frame_incognito": [ -1, -1, -1 ], - "frame_incognito_inactive": [ -1, -1, -1 ] - } - }, - "version": "2" -} -EOF -) - diff --git a/.config/mode/switch.d/chromium b/.config/mode/switch.d/chromium new file mode 100755 index 0000000..532510a --- /dev/null +++ b/.config/mode/switch.d/chromium @@ -0,0 +1,45 @@ +#!/bin/sh +PREFIX="$XDG_DATA_HOME/mode/chromium" + +mkdir -p "$PREFIX" +rm -f "$PREFIX/Cached Theme.pak" + +convert -size 100x100 "xc:$bg" "$PREFIX/bg.png" +bg_alt=$(mix_rgb $color7 $bg 0.20) +fg_alt=$(mix_rgb $color15 $fg 0.60) +bg="$(hex_to_rgb_array "$bg")" +fg="$(hex_to_rgb_array "$fg")" +bg_alt="$(hex_to_rgb_array "$bg_alt")" +fg_alt="$(hex_to_rgb_array "$fg_alt")" +cat << EOF > "$PREFIX/manifest.json" +{ + "description": "colorscheme generated by mode", + "manifest_version": 2, + "name": "mode theme", + "theme": { + "images": { "theme_frame": "bg.png" }, + "colors": { + "frame": $bg, + "button_background": $fg, + "ntp_background": $bg, + "ntp_text": $bg, + "toolbar": $bg_alt, + "toolbar_button_icon": $fg, + "tab_background_text": $fg_alt, + "tab_background_text_inactive": $fg_alt, + "tab_background_text_incognito": $fg_alt, + "tab_background_text_incognito_inactive": $fg_alt, + "bookmark_text": $fg, + "tab_text": $fg + }, + "tints": { + "buttons": [ -1, -1, -1 ], + "frame_inactive": [ -1, -1, -1 ], + "frame_incognito": [ -1, -1, -1 ], + "frame_incognito_inactive": [ -1, -1, -1 ] + } + }, + "version": "2" +} +EOF + diff --git a/.local/share/applications/discord.desktop b/.local/share/applications/discord.desktop new file mode 100644 index 0000000..676b330 --- /dev/null +++ b/.local/share/applications/discord.desktop @@ -0,0 +1,9 @@ +[Desktop Entry] +Name=Discord +StartupWMClass=discord +Comment=All-in-one voice and text chat for gamers that's free, secure, and works on both your desktop and phone. +GenericName=Internet Messenger +Exec=discord +Icon=discord +Type=Application +Categories=Network;InstantMessaging; diff --git a/.local/share/bin/decsync2plain b/.local/share/bin/decsync2plain index 2bb9be2..5cb7eec 100755 --- a/.local/share/bin/decsync2plain +++ b/.local/share/bin/decsync2plain @@ -33,7 +33,7 @@ fi # auto detect extension if not explicitly provided if [ -z "$EXTENSION" ] ; then - EXTENSION="$(realpath "$PWD" | tr '/' '\n' | sort -r | while read -r folder ; do + EXTENSION="$(realpath "$PWD" | tr '/' '\n' | tac | while read -r folder ; do case "$folder" in calendars|tasks) echo ics ; break ;; contacts) echo vcf ; break ;; diff --git a/.local/share/bin/discord b/.local/share/bin/discord new file mode 100755 index 0000000..d2f894b --- /dev/null +++ b/.local/share/bin/discord @@ -0,0 +1,3 @@ +#!/bin/sh +installbd +exec /usr/bin/discord "$@" diff --git a/.local/share/bin/installbd b/.local/share/bin/installbd new file mode 100755 index 0000000..eefe92a --- /dev/null +++ b/.local/share/bin/installbd @@ -0,0 +1,28 @@ +#!/bin/sh +discord_path="$(dirname "$(find "$XDG_CONFIG_HOME/discord" -name core.asar)")" +discord_version="$(echo "$discord_path" | tr '/' '\n' | tac | sed -n '/^[0-9.]\+$/p' | head -n1)" +betterdiscord_path="$XDG_CONFIG_HOME/BetterDiscord/data/betterdiscord.asar" +cache_file="$XDG_CACHE_HOME/bdversion" + +# download betterdiscord.asar by default +download=1 +# do not do download if discord hasn't been updated since the last time this +# script was run +[ -e "$cache_file" ] && [ "$discord_version" = "$(cat "$cache_file")" ] && download=0 +# always download if betterdiscord.asar does not exist +[ ! -e "$betterdiscord_path" ] && download=1 + +if [ $download -eq 1 ] ; then + echo "download betterdiscord.asar" + curl -sLo - 'https://betterdiscord.app/Download/betterdiscord.asar' > "$betterdiscord_path" +fi +if ! grep "$(basename "$betterdiscord_path")" "$discord_path/index.js" > /dev/null ; then + echo "patch discord desktop core index.js" + printf 'require("%s");\n%s' "$betterdiscord_path" "$(cat "$discord_path/index.js")" > "$discord_path/index.js" +fi + +# store discord version used for this install +mkdir -p "$(dirname "$cache_file")" +echo "$discord_version" > "$cache_file" + +echo "done!" diff --git a/.local/share/bin/nodisconnect b/.local/share/bin/nodisconnect index 0c65d13..b4fb2c3 100755 --- a/.local/share/bin/nodisconnect +++ b/.local/share/bin/nodisconnect @@ -1,6 +1,9 @@ #!/bin/sh # use sox to play very quiet noise for keeping bluetooth headphones connected +# kill any previously running processes +killall -u "$LOGNAME" play + # arguments used: # -q quiet mode (don't output progress bar) # -n null input filename (because synth is used as input) diff --git a/.profile b/.profile index dba7107..e1af117 100644 --- a/.profile +++ b/.profile @@ -16,6 +16,8 @@ alias mk="make" alias sl="sl -w" alias vv="neovide" alias today="khal list today today" +alias bctl="bluetoothctl" +alias sctl="systemctl --user" # one letters alias r="ranger" @@ -26,6 +28,8 @@ alias n="ncmpcpp" alias c="khal" alias f="fork" alias p="pass" +alias b="bluetoothctl" +alias s="systemctl --user" # "functions" alias reload="sudo systemctl restart lightdm" -- cgit v1.2.3