feat: replace i3wm with hyprland

This commit is contained in:
Ryan Yin
2023-05-04 23:59:35 +08:00
committed by ryan4yin
parent 9e549fb733
commit 830605aeec
59 changed files with 1947 additions and 42 deletions
+54
View File
@@ -0,0 +1,54 @@
#!/usr/bin/env bash
## Script To Manage Brightness For Archcraft (in Wayland).
iDIR="$HOME/.config/hypr/mako/icons"
# Get brightness
get_backlight() {
LIGHT=$(printf "%.0f\n" $(light -G))
echo "${LIGHT}%"
}
# Get icons
get_icon() {
backlight="$(get_backlight)"
current="${backlight%%%}"
if [[ ("$current" -ge "0") && ("$current" -le "20") ]]; then
icon="$iDIR/brightness-20.png"
elif [[ ("$current" -ge "20") && ("$current" -le "40") ]]; then
icon="$iDIR/brightness-40.png"
elif [[ ("$current" -ge "40") && ("$current" -le "60") ]]; then
icon="$iDIR/brightness-60.png"
elif [[ ("$current" -ge "60") && ("$current" -le "80") ]]; then
icon="$iDIR/brightness-80.png"
elif [[ ("$current" -ge "80") && ("$current" -le "100") ]]; then
icon="$iDIR/brightness-100.png"
fi
}
# Notify
notify_user() {
notify-send -h string:x-canonical-private-synchronous:sys-notify -u low -i "$icon" "Brightness : $(get_backlight)"
}
# Increase brightness
inc_backlight() {
light -A 5 && get_icon && notify_user
}
# Decrease brightness
dec_backlight() {
light -U 5 && get_icon && notify_user
}
# Execute accordingly
if [[ "$1" == "--get" ]]; then
get_backlight
elif [[ "$1" == "--inc" ]]; then
inc_backlight
elif [[ "$1" == "--dec" ]]; then
dec_backlight
else
get_backlight
fi
+20
View File
@@ -0,0 +1,20 @@
#!/usr/bin/env bash
## Simple Script To Pick Color Quickly.
color=$(grim -g "$(slurp -b 1B1F2800 -p)" -t ppm - | convert - -format '%[pixel:p{0,0}]' txt:- | tail -n1 | cut -d' ' -f4)
image=/tmp/${color}.png
main() {
if [[ "$color" ]]; then
# copy color code to clipboard
echo $color | tr -d "\n" | wl-copy
# generate preview
convert -size 48x48 xc:"$color" ${image}
# notify about it
notify-send -h string:x-canonical-private-synchronous:sys-notify -u low -i ${image} "$color, copied to clipboard."
fi
}
# Run the script
main
+19
View File
@@ -0,0 +1,19 @@
#!/usr/bin/env bash
## Set GTK Themes, Icons, Cursor and Fonts
THEME='Arc-Dark'
ICONS='Zafiro-Blue'
FONT='Noto Sans 9'
CURSOR='Qogirr'
SCHEMA='gsettings set org.gnome.desktop.interface'
apply_themes () {
${SCHEMA} gtk-theme "$THEME"
${SCHEMA} icon-theme "$ICONS"
${SCHEMA} cursor-theme "$CURSOR"
${SCHEMA} font-name "$FONT"
}
apply_themes
+70
View File
@@ -0,0 +1,70 @@
#!/usr/bin/env bash
# Background Image
IMAGE="$HOME/.config/hypr/wallpapers/lockscreen.png"
# Colors
bg='1e1e2e' bgl='313244' fg='d9e0ee'
red='f38ba8' green='a6e3a1' yellow='f9e2af'
blue='89b4fa' magenta='cba6f7' cyan='89dceb'
alpha='00000000'
# CMD
swaylock -f \
\
`# General` \
--ignore-empty-password \
--show-failed-attempts \
--hide-keyboard-layout \
--indicator-caps-lock \
\
`# Appearance` \
--color ${bg}E6 \
`#--image ${IMAGE} --scaling fill` \
--font 'JetBrainsMono Nerd Font' --font-size 18 \
\
`# Backspace Key` \
--key-hl-color ${green} \
--caps-lock-key-hl-color ${blue} \
--bs-hl-color ${red} \
--caps-lock-bs-hl-color ${red} \
\
`# Indicator` \
--indicator-radius 120 \
--indicator-thickness 10 \
\
`# Inside Circle Colors` \
--inside-color ${alpha} \
--inside-clear-color ${alpha} \
--inside-caps-lock-color ${alpha} \
--inside-ver-color ${blue} \
--inside-wrong-color ${red} \
\
`# Layout Colors` \
--layout-bg-color ${cyan} \
--layout-border-color ${cyan} \
--layout-text-color ${bg} \
\
`# Line Colors` \
--line-color ${bg} \
--line-clear-color ${red} \
--line-caps-lock-color ${bg} \
--line-ver-color ${bg} \
--line-wrong-color ${bg} \
\
`# Ring Colors` \
--ring-color ${cyan} \
--ring-clear-color ${bg} \
--ring-caps-lock-color ${magenta} \
--ring-ver-color ${blue} \
--ring-wrong-color ${red} \
\
`# Separator Color` \
--separator-color ${bg} \
\
`# Text Colors` \
--text-color ${fg} \
--text-clear-color ${fg} \
--text-caps-lock-color ${fg} \
--text-ver-color ${bg} \
--text-wrong-color ${bg}
+13
View File
@@ -0,0 +1,13 @@
#!/usr/bin/env bash
## launch wofi with alt config
CONFIG="$HOME/.config/hypr/wofi/config"
STYLE="$HOME/.config/hypr/wofi/style.css"
COLORS="$HOME/.config/hypr/wofi/colors"
if [[ ! $(pidof wofi) ]]; then
wofi --show drun --prompt 'Search...' --conf ${CONFIG} --style ${STYLE} --color ${COLORS}
else
pkill wofi
fi
+9
View File
@@ -0,0 +1,9 @@
#!/usr/bin/env bash
## launch mako with alt config
CONFIG="$HOME/.config/hypr/mako/config"
if [[ ! $(pidof mako) ]]; then
mako --config ${CONFIG}
fi
+83
View File
@@ -0,0 +1,83 @@
#!/usr/bin/env bash
## Wofi Powermenu
## Files
CONFIG="$HOME/.config/hypr/wofi/config"
STYLE="$HOME/.config/hypr/wofi/style.css"
COLORS="$HOME/.config/hypr/wofi/colors"
## Wofi Command
wofi_command="wofi --show dmenu \
--conf ${CONFIG} --style ${STYLE} --color ${COLORS} \
--width=300 --height=165 \
--cache-file=/dev/null \
--hide-scroll --no-actions \
--define=matching=fuzzy"
uptime=$(uptime -p | sed -e 's/up //g')
## Entries
shutdown=" Shutdown"
reboot=" Restart"
lock=" Lock"
suspend=" Sleep"
logout=" Logout"
# Ask for confirmation
cdialog () {
yad --title='Confirm?' --borders=15 --center --fixed --undecorated --button=Yes:0 --button=No:1 --text="Are you sure?" --text-align=center
}
# Variable passed to rofi
open_menu () {
options="$lock\n$suspend\n$logout\n$reboot\n$shutdown"
chosen="$(echo -e "$options" | $wofi_command --prompt "UP - $uptime")"
case $chosen in
$shutdown)
cdialog
if [[ "$?" == 0 ]]; then
systemctl poweroff
else
exit
fi
;;
$reboot)
cdialog
if [[ "$?" == 0 ]]; then
systemctl reboot
else
exit
fi
;;
$lock)
~/.config/hypr/scripts/lockscreen
;;
$suspend)
cdialog
if [[ "$?" == 0 ]]; then
mpc -q pause
amixer set Master mute
~/.config/hypr/scripts/lockscreen
systemctl suspend
else
exit
fi
;;
$logout)
cdialog
if [[ "$?" == 0 ]]; then
kill -9 -1
else
exit
fi
;;
esac
}
if [[ ! $(pidof wofi) ]]; then
open_menu
else
pkill wofi
fi
+79
View File
@@ -0,0 +1,79 @@
#!/usr/bin/env bash
## Script to take screenshots with grim, slurp (in Wayland)
iDIR="$HOME/.config/hypr/mako/icons"
time=$(date +%Y-%m-%d-%H-%M-%S)
dir="$(xdg-user-dir PICTURES)/Screenshots"
file="Screenshot_${time}_${RANDOM}.png"
# notify and view screenshot
notify_cmd_shot="notify-send -h string:x-canonical-private-synchronous:shot-notify -u low -i ${iDIR}/picture.png"
notify_view () {
${notify_cmd_shot} "Copied to clipboard."
viewnior ${dir}/"$file"
if [[ -e "$dir/$file" ]]; then
${notify_cmd_shot} "Screenshot Saved."
else
${notify_cmd_shot} "Screenshot Deleted."
fi
}
# countdown
countdown () {
for sec in $(seq $1 -1 1); do
notify-send -h string:x-canonical-private-synchronous:shot-notify -t 1000 -i "$iDIR"/timer.png "Taking shot in : $sec"
sleep 1
done
}
# take shots
shotnow () {
cd ${dir} && grim - | tee "$file" | wl-copy
notify_view
}
shot5 () {
countdown '5'
sleep 1 && cd ${dir} && grim - | tee "$file" | wl-copy
notify_view
}
shot10 () {
countdown '10'
sleep 1 && cd ${dir} && grim - | tee "$file" | wl-copy
notify_view
}
shotwin () {
w_pos=$(hyprctl activewindow | grep 'at:' | cut -d':' -f2 | tr -d ' ' | tail -n1)
w_size=$(hyprctl activewindow | grep 'size:' | cut -d':' -f2 | tr -d ' ' | tail -n1 | sed s/,/x/g)
cd ${dir} && grim -g "$w_pos $w_size" - | tee "$file" | wl-copy
notify_view
}
shotarea () {
cd ${dir} && grim -g "$(slurp -b 1B1F28CC -c E06B74ff -s C778DD0D -w 2)" - | tee "$file" | wl-copy
notify_view
}
if [[ ! -d "$dir" ]]; then
mkdir -p "$dir"
fi
if [[ "$1" == "--now" ]]; then
shotnow
elif [[ "$1" == "--in5" ]]; then
shot5
elif [[ "$1" == "--in10" ]]; then
shot10
elif [[ "$1" == "--win" ]]; then
shotwin
elif [[ "$1" == "--area" ]]; then
shotarea
else
echo -e "Available Options : --now --in5 --in10 --win --area"
fi
exit 0
+29
View File
@@ -0,0 +1,29 @@
#!/usr/bin/env bash
## Autostart Programs
# Kill already running process
_ps=(waybar mako mpd xfce-polkit)
for _prs in "${_ps[@]}"; do
if [[ $(pidof ${_prs}) ]]; then
killall -9 ${_prs}
fi
done
# Polkit agent
/usr/lib/xfce-polkit/xfce-polkit &
# Set wallpaper
swaybg --output '*' --mode fill --image ~/.config/hypr/wallpapers/wallpaper.png &
# Apply themes
~/.config/hypr/scripts/gtkthemes &
# Lauch notification daemon (mako)
~/.config/hypr/scripts/notifications &
# Lauch statusbar (waybar)
~/.config/hypr/scripts/statusbar &
# Start mpd
exec mpd &
+10
View File
@@ -0,0 +1,10 @@
#!/usr/bin/env bash
## launch waybar with alt config
CONFIG="$HOME/.config/hypr/waybar/config"
STYLE="$HOME/.config/hypr/waybar/style.css"
if [[ ! $(pidof waybar) ]]; then
waybar --bar main-bar --log-level error --config ${CONFIG} --style ${STYLE}
fi
+16
View File
@@ -0,0 +1,16 @@
#!/usr/bin/env bash
## launch terminal with alt config
CONFIG="$HOME/.config/hypr/foot/foot.ini"
if [ "$1" == "-f" ]; then
foot --app-id='foot-float' --config="$CONFIG"
elif [ "$1" == "-F" ]; then
foot --fullscreen --app-id='foot-full' --font="Iosevka Nerd Font:size=14" --override=pad=35x35 --config="$CONFIG"
elif [ "$1" == "-s" ]; then
foot --app-id='foot-float' --config="$CONFIG" \
--window-size-pixels=$(slurp -b 1B1F28CC -c E06B74ff -s C778DD0D -w 2 -f "%wx%h")
else
foot --config="$CONFIG"
fi
+76
View File
@@ -0,0 +1,76 @@
#!/usr/bin/env bash
## Script To Manage Speaker Volume For Archcraft (in Wayland).
iDIR="$HOME/.config/hypr/mako/icons"
# Get Volume
get_volume() {
volume=$(amixer get Master | tail -n1 | awk -F ' ' '{print $5}' | tr -d '[]')
echo "$volume"
}
# Get icons
get_icon() {
vol="$(get_volume)"
current="${vol%%%}"
if [[ "$current" -eq "0" ]]; then
icon="$iDIR/volume-mute.png"
elif [[ ("$current" -ge "0") && ("$current" -le "30") ]]; then
icon="$iDIR/volume-low.png"
elif [[ ("$current" -ge "30") && ("$current" -le "60") ]]; then
icon="$iDIR/volume-mid.png"
elif [[ ("$current" -ge "60") && ("$current" -le "100") ]]; then
icon="$iDIR/volume-high.png"
fi
}
# Notify
notify_user() {
notify-send -h string:x-canonical-private-synchronous:sys-notify -u low -i "$icon" "Volume : $(get_volume)"
}
# Increase Volume
inc_volume() {
amixer -Mq set Master,0 5%+ unmute && get_icon && notify_user
}
# Decrease Volume
dec_volume() {
amixer -Mq set Master,0 5%- unmute && get_icon && notify_user
}
# Toggle Mute
toggle_mute() {
amixer get Master | grep '\[on\]' &>/dev/null
if [[ "$?" == 0 ]]; then
amixer set Master toggle && notify-send -h string:x-canonical-private-synchronous:sys-notify -u low -i "$iDIR/volume-mute.png" "Mute"
else
amixer set Master toggle && get_icon && notify-send -h string:x-canonical-private-synchronous:sys-notify -u low -i "$icon" "Unmute"
fi
}
# Toggle Mic
toggle_mic() {
amixer get Capture | grep '\[on\]' &>/dev/null
if [[ "$?" == 0 ]]; then
amixer -D pulse sset Capture toggle && notify-send -h string:x-canonical-private-synchronous:sys-notify -u low -i "$iDIR/microphone-mute.png" "Microphone Switched OFF"
else
amixer -D pulse sset Capture toggle && get_icon && notify-send -h string:x-canonical-private-synchronous:sys-notify -u low -i "$iDIR/microphone.png" "Microphone Switched ON"
fi
}
# Execute accordingly
if [[ "$1" == "--get" ]]; then
get_volume
elif [[ "$1" == "--inc" ]]; then
inc_volume
elif [[ "$1" == "--dec" ]]; then
dec_volume
elif [[ "$1" == "--toggle" ]]; then
toggle_mute
elif [[ "$1" == "--toggle-mic" ]]; then
toggle_mic
else
get_volume
fi
+79
View File
@@ -0,0 +1,79 @@
#!/usr/bin/env bash
cachedir=~/.cache/rbn
cachefile=${0##*/}-$1
if [ ! -d $cachedir ]; then
mkdir -p $cachedir
fi
if [ ! -f $cachedir/$cachefile ]; then
touch $cachedir/$cachefile
fi
# Save current IFS
SAVEIFS=$IFS
# Change IFS to new line.
IFS=$'\n'
cacheage=$(($(date +%s) - $(stat -c '%Y' "$cachedir/$cachefile")))
if [ $cacheage -gt 1740 ] || [ ! -s $cachedir/$cachefile ]; then
data=($(curl -s https://en.wttr.in/$1\?0qnT 2>&1))
echo ${data[0]} | cut -f1 -d, > $cachedir/$cachefile
echo ${data[1]} | sed -E 's/^.{15}//' >> $cachedir/$cachefile
echo ${data[2]} | sed -E 's/^.{15}//' >> $cachedir/$cachefile
fi
weather=($(cat $cachedir/$cachefile))
# Restore IFSClear
IFS=$SAVEIFS
temperature=$(echo ${weather[2]} | sed -E 's/([[:digit:]])+\.\./\1 to /g')
#echo ${weather[1]##*,}
# https://fontawesome.com/icons?s=solid&c=weather
case $(echo ${weather[1]##*,} | tr '[:upper:]' '[:lower:]') in
"clear" | "sunny")
condition=""
;;
"partly cloudy")
condition="杖"
;;
"cloudy")
condition=""
;;
"overcast")
condition=""
;;
"mist" | "fog" | "freezing fog")
condition=""
;;
"patchy rain possible" | "patchy light drizzle" | "light drizzle" | "patchy light rain" | "light rain" | "light rain shower" | "rain")
condition=""
;;
"moderate rain at times" | "moderate rain" | "heavy rain at times" | "heavy rain" | "moderate or heavy rain shower" | "torrential rain shower" | "rain shower")
condition=""
;;
"patchy snow possible" | "patchy sleet possible" | "patchy freezing drizzle possible" | "freezing drizzle" | "heavy freezing drizzle" | "light freezing rain" | "moderate or heavy freezing rain" | "light sleet" | "ice pellets" | "light sleet showers" | "moderate or heavy sleet showers")
condition="ﭽ"
;;
"blowing snow" | "moderate or heavy sleet" | "patchy light snow" | "light snow" | "light snow showers")
condition="流"
;;
"blizzard" | "patchy moderate snow" | "moderate snow" | "patchy heavy snow" | "heavy snow" | "moderate or heavy snow with thunder" | "moderate or heavy snow showers")
condition="ﰕ"
;;
"thundery outbreaks possible" | "patchy light rain with thunder" | "moderate or heavy rain with thunder" | "patchy light snow with thunder")
condition=""
;;
*)
condition=""
echo -e "{\"text\":\""$condition"\", \"alt\":\""${weather[0]}"\", \"tooltip\":\""${weather[0]}: $temperature ${weather[1]}"\"}"
;;
esac
#echo $temp $condition
echo -e "{\"text\":\""$temperature $condition"\", \"alt\":\""${weather[0]}"\", \"tooltip\":\""${weather[0]}: $temperature ${weather[1]}"\"}"
+19
View File
@@ -0,0 +1,19 @@
#!/usr/bin/env bash
## wlogout with alt layout and style file
LAYOUT="$HOME/.config/hypr/wlogout/layout"
STYLE="$HOME/.config/hypr/wlogout/style.css"
if [[ ! $(pidof wlogout) ]]; then
wlogout --layout ${LAYOUT} --css ${STYLE} \
--buttons-per-row 5 \
--column-spacing 50 \
--row-spacing 50 \
--margin-top 390 \
--margin-bottom 390 \
--margin-left 150 \
--margin-right 150
else
pkill wlogout
fi