diff --git a/Scripts/basic/brightness b/Scripts/basic/brightness index 6542bd4..3d00bc0 100755 --- a/Scripts/basic/brightness +++ b/Scripts/basic/brightness @@ -8,8 +8,10 @@ # read about it on archwiki(backlight) # Author: totoro -BRIGHTNESS_FILE="/sys/class/backlight/intel_backlight/brightness" -MAX_BRIGHTNESS_FILE="/sys/class/backlight/intel_backlight/max_brightness" +BACKLIGHT="/sys/class/backlight/intel_backlight" + +BRIGHTNESS_FILE="$BACKLIGHT/brightness" +MAX_BRIGHTNESS_FILE="$BACKLIGHT/max_brightness" CUR_BRI=$(cat "$BRIGHTNESS_FILE") MAX_BRI=$(cat "$MAX_BRIGHTNESS_FILE") @@ -17,17 +19,40 @@ MAX_BRI=$(cat "$MAX_BRIGHTNESS_FILE") # calculating 5 percent of max-brightness ((STEP = MAX_BRI * 5 / 100)) +display_notification() { + local value="$1" + local text="$2" + OPTIONS=( + "--appname=Brightness" # Name of your application + "Brightness" + "$text \nBrightness: " + "--hints=int:value:$value" # User specified hints + "--replace=100" # Set id of this notification + "--icon=brightness-systray" # An Icon that should be displayed with the notification + ) + dunstify "${OPTIONS[@]}" +} + +notify_polybar() { + # enable ipc control to change brightness + if pgrep -x "polybar" >/dev/null; then + polybar-msg hook brightness 1 + fi + sleep 0.1 +} + case $1 in -inc) ((NEW_BRI = CUR_BRI + STEP)) if ((NEW_BRI < MAX_BRI)); then echo $NEW_BRI | tee "$BRIGHTNESS_FILE" ((NEW_PER = NEW_BRI * 100 / MAX_BRI)) - dunstify -a "Brightness" "Brightness" "Increase \nBrightness: " -h int:value:$NEW_PER -r 100 -i brightness-systray else - echo $MAX_BRI | tee "$BRIGHTNESS_FILE" - dunstify -a "Brightness" "Brightness" "Increase \nBrightness: " -h int:value:100 -r 100 -i brightness-systray + echo "$MAX_BRI" | tee "$BRIGHTNESS_FILE" + NEW_PER="100" fi + display_notification "$NEW_PER" "Increase" + notify_polybar ;; -dec) # calculating MIN_BRI @@ -39,13 +64,11 @@ case $1 in echo $MIN_BRI | tee "$BRIGHTNESS_FILE" fi ((NEW_PER = NEW_BRI * 100 / MAX_BRI)) - dunstify -a "Brightness" "Brightness" "Decrease \nBrightness: " -h int:value:$NEW_PER -r 100 -i brightness-systray + display_notification "$NEW_PER" "Decrease" + notify_polybar ;; *) - echo "Invalid arguments." + # display current brightness + echo $((CUR_BRI * 100 / MAX_BRI)) ;; -esac - -# enable ipc control to change brightness -polybar-msg hook brightness 1 -sleep 0.1 +esac \ No newline at end of file diff --git a/Scripts/basic/set-theme b/Scripts/basic/set-theme index 0b3c21d..2c1f51f 100755 --- a/Scripts/basic/set-theme +++ b/Scripts/basic/set-theme @@ -1,4 +1,5 @@ #!/bin/bash +# light and dark theme switcher # Check if an argument is provided if [ $# -ne 1 ]; then @@ -13,40 +14,60 @@ theme=$1 if [ "$theme" = "light" ]; then echo "Setting light theme..." - # gtk - gsettings set org.gnome.desktop.interface color-scheme 'default' - gsettings set org.gnome.desktop.interface icon-theme 'ePapirus' + # generic across all de/wm + # terminal + alacritty-conf -c atom_one_light - gnome-extensions enable lightshell@dikasp.gitlab + case "$DESKTOP_SESSION" in + gnome) + # gtk + gsettings set org.gnome.desktop.interface color-scheme 'default' + gsettings set org.gnome.desktop.interface icon-theme 'ePapirus' - # qt - cp "$HOME/.config/qt5ct/light.conf" "$HOME/.config/qt5ct/qt5ct.conf" + # tray icons change contrast so they can be seen + dconf write /org/gnome/shell/extensions/appindicator/icon-contrast -1.0 - # terminal - alacritty-conf -c atom_one_light + gnome-extensions enable lightshell@dikasp.gitlab + + # qt + cp "$HOME/.config/qt5ct/light.conf" "$HOME/.config/qt5ct/qt5ct.conf" - # wallpaper using variety - variety --set-option icon Dark --set-option lightness_mode 1 - variety --next + # wallpaper using variety + variety --set-option icon Dark --set-option lightness_mode 1 + variety --next + ;; + i3) + echo "no theme setup" + ;; + esac elif [ "$theme" = "dark" ]; then echo "Setting dark theme..." - gsettings set org.gnome.desktop.interface color-scheme 'prefer-dark' - gsettings set org.gnome.desktop.interface icon-theme 'ePapirus-Dark' + # terminal + alacritty-conf -c alacritty_0_12 - gnome-extensions disable lightshell@dikasp.gitlab + case "$DESKTOP_SESSION" in + gnome) + gsettings set org.gnome.desktop.interface color-scheme 'prefer-dark' + gsettings set org.gnome.desktop.interface icon-theme 'ePapirus-Dark' - # qt - cp "$HOME/.config/qt5ct/dark.conf" "$HOME/.config/qt5ct/qt5ct.conf" + # tray icons reset contrast back so they can be seen + dconf write /org/gnome/shell/extensions/appindicator/icon-contrast 0.0 - # terminal - alacritty-conf -c alacritty_0_12 + gnome-extensions disable lightshell@dikasp.gitlab - # wallpaper using variety - variety --set-option icon Light --set-option lightness_mode 0 - variety --next + # qt + cp "$HOME/.config/qt5ct/dark.conf" "$HOME/.config/qt5ct/qt5ct.conf" + # wallpaper using variety + variety --set-option icon Light --set-option lightness_mode 0 + variety --next + ;; + i3) + echo "no theme set" + ;; + esac else echo "Invalid argument. Usage: $0 " exit 1 diff --git a/Scripts/i3/start-gnome-keyring.sh b/Scripts/i3/start-gnome-keyring.sh new file mode 100755 index 0000000..ac6b0a8 --- /dev/null +++ b/Scripts/i3/start-gnome-keyring.sh @@ -0,0 +1,2 @@ +eval $(/usr/bin/gnome-keyring-daemon --start --components=gpg,pkcs11,secrets,ssh) +export GNOME_KEYRING_CONTROL GNOME_KEYRING_PID GPG_AGENT_INFO SSH_AUTH_SOCK diff --git a/Scripts/shell/alias.sh b/Scripts/shell/alias.sh index 2d98f59..83b9fc8 100644 --- a/Scripts/shell/alias.sh +++ b/Scripts/shell/alias.sh @@ -8,4 +8,4 @@ alias ll='exa -all' alias ls='exa -all' alias xo='xdg-open' alias pdftk='java -jar $HOME/.local/bin/pdftk-all.jar' -alias alert='notify-send --urgency=low -i "$([ $? = 0 ] && echo terminal || echo error)" "$(history|tail -n1|sed -e '\''s/^\s*[0-9]\+\s*//;s/[;&|]\s*alert$//'\'')"' \ No newline at end of file +alias alert='notify-send --urgency=low -i "$([ $? = 0 ] && echo terminal || echo error)" "$(history|tail -n1|sed -e '\''s/^\s*[0-9]\+\s*//;s/[;&|]\s*alert$//'\'')"' diff --git a/Scripts/shell/env.sh b/Scripts/shell/env.sh index b46e70b..a5c15d8 100644 --- a/Scripts/shell/env.sh +++ b/Scripts/shell/env.sh @@ -19,3 +19,6 @@ export GCC_COLORS='error=01;31:warning=01;35:note=01;36:caret=01;32:locus=01:quo # java export _JAVA_OPTIONS='-Dawt.useSystemAAFontSettings=lcd' + +# go +export PATH=$PATH:/usr/local/go/bin \ No newline at end of file diff --git a/Scripts/shell/functions.sh b/Scripts/shell/functions.sh index 26b09fa..61b111c 100644 --- a/Scripts/shell/functions.sh +++ b/Scripts/shell/functions.sh @@ -1,3 +1,7 @@ +get-tabs(){ + strings $HOME/.config/google-chrome/Default/Sessions/Session_* | grep -E '^https?://' | sed 's|/$||g' | sort | uniq | grep -v 'google.com' +} + bookmarks(){ grep -i "$1" $HOME/Documents/todo/bookmarks/*.md } @@ -160,4 +164,4 @@ lfcd () { dir="$(cat "$tmp")" [ -d "$dir" ] && [ "$dir" != "$(pwd)" ] && cd "$dir" fi -} \ No newline at end of file +} diff --git a/Scripts/tools/chrome/switchRecentTab.sh b/Scripts/tools/chrome/switchRecentTab.sh new file mode 100755 index 0000000..fc53692 --- /dev/null +++ b/Scripts/tools/chrome/switchRecentTab.sh @@ -0,0 +1,25 @@ +#!/bin/bash + +# Get the window ID of the currently focused window +WINDOW_ID=$(xdotool getwindowfocus) +# zenity --info --text="$WINDOW_ID" +# Get the class name of the window +WINDOW_CLASS=$(xprop -id $WINDOW_ID | grep "WM_CLASS" | awk -F '"' '{print $4}') + +# Check if the window class name is 'google-chrome' +if [ "$WINDOW_CLASS" == "Google-chrome" ]; then + xdotool key ctrl+Tab + # xdotool windowactivate --sync $WINDOW_ID + # sleep 0.2 + # xdotool key ctrl+shift+a + # xdotool key Return + # xdotool --window $WINDOW_ID keydown ctrl + # xdotool --window $WINDOW_ID keydown shift + # xdotool --window $WINDOW_ID key a + # xdotool --window $WINDOW_ID keyup shift + # xdotool --window $WINDOW_ID keyup ctrl + # zenity --info --text="shivanshu" +else + xdotool key ctrl+Tab +fi +