Skip to content

Commit

Permalink
fixed tray icons for light theme
Browse files Browse the repository at this point in the history
  • Loading branch information
shivanshu-semwal committed Aug 21, 2024
1 parent ea91674 commit 5205bb9
Show file tree
Hide file tree
Showing 7 changed files with 113 additions and 35 deletions.
47 changes: 35 additions & 12 deletions Scripts/basic/brightness
Original file line number Diff line number Diff line change
Expand Up @@ -8,26 +8,51 @@
# 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")

# 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
Expand All @@ -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
63 changes: 42 additions & 21 deletions Scripts/basic/set-theme
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/bin/bash
# light and dark theme switcher

# Check if an argument is provided
if [ $# -ne 1 ]; then
Expand All @@ -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 [email protected]
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 [email protected]

# 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 [email protected]
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 [email protected]

# 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 <light|dark>"
exit 1
Expand Down
2 changes: 2 additions & 0 deletions Scripts/i3/start-gnome-keyring.sh
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion Scripts/shell/alias.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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$//'\'')"'
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$//'\'')"'
3 changes: 3 additions & 0 deletions Scripts/shell/env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
6 changes: 5 additions & 1 deletion Scripts/shell/functions.sh
Original file line number Diff line number Diff line change
@@ -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
}
Expand Down Expand Up @@ -160,4 +164,4 @@ lfcd () {
dir="$(cat "$tmp")"
[ -d "$dir" ] && [ "$dir" != "$(pwd)" ] && cd "$dir"
fi
}
}
25 changes: 25 additions & 0 deletions Scripts/tools/chrome/switchRecentTab.sh
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 5205bb9

Please sign in to comment.