diff --git a/.gitignore b/.gitignore index 54497c2..ff0ac5d 100644 --- a/.gitignore +++ b/.gitignore @@ -27,3 +27,6 @@ zoom* systemd sunshine uad +intelephense +rustdesk +ristretto diff --git a/env.example b/env.example index 2235abd..17aaf86 100644 --- a/env.example +++ b/env.example @@ -40,3 +40,13 @@ matrix_creds() { MX_TOKEN= MX_URL= } + +navidrome_creds() { + # unload + [ "$1" = "unload" ] && unset ND_USER ND_PASS ND_URL && return 0 + + # load + ND_USER= + ND_PASS= + ND_URL= +} diff --git a/hypr/battery b/hypr/battery index 1df0f7e..a7f5da5 100755 --- a/hypr/battery +++ b/hypr/battery @@ -1,7 +1,7 @@ #!/bin/sh notify() { - notify-send -e -i "$icon_dir/$1" -h "string:x-canonical-private-synchronous:${0##*/}" "$2" -u "${3:-normal}" + notify-send -e -t 5000 -i "${icon_dir}${1}" -h "string:x-canonical-private-synchronous:${0##*/}" "$2" -u "${3:-normal}" } print_sleep() { @@ -9,36 +9,54 @@ print_sleep() { sleep "$1" } +switch_to_ac_mode() { + charge_icon=$(printf "%03d" "$((charge / 10))0") + hyprctl keyword monitor 'eDP-1',preferred,auto,1.5,bitdepth,10 + hyprctl keyword decoration:blur:enabled true + hyprctl keyword decoration:shadow:enabled true + notify "battery-$charge_icon-charging.svg" "AC Mode ($charge%, Charging)" + exit 0 +} + +switch_to_battery_mode() { + charge_icon=$(printf "%03d" "$((charge / 10))0") + hyprctl keyword monitor 'eDP-1',$battery_resolution,auto,1.5,bitdepth,10 + hyprctl keyword decoration:blur:enabled false + hyprctl keyword decoration:shadow:enabled false + notify "battery-$charge_icon.svg" "Battery Mode ($charge%, Discharging)" + exit 0 +} #declaration +dir="/sys/class/power_supply/" battery="BAT0" #change accordingly -dir="/sys/class/power_supply/$battery/" +battery_dir="${dir}${battery}/" icon_dir="/usr/share/icons/Papirus-Dark/22x22/panel/" #change accordingly i=0 status="normal" -charge=$(cat "$dir"/capacity) -power_status=$(cat "$dir"/status) +charge=$(cat "$battery_dir"/capacity) +battery_resolution="2880x1800@48" # widthxheight@refresh_rate case "$1" in - ac) - notify "battery-$(( charge / 10))0-charging.svg" "Power: AC Mode ($charge % $power_status)" - hyprctl keyword decoration:blur:enabled true - hyprctl keyword decoration:shadow:enabled true - exit 0 - ;; + ac) + switch_to_ac_mode + ;; - battery) - notify "battery-$(( charge / 10))0.svg" "Power: Battery Mode ($charge % $power_status)" - hyprctl keyword decoration:blur:enabled false - hyprctl keyword decoration:shadow:enabled false - exit 0 - ;; + battery) + switch_to_battery_mode + ;; + check) + if [ "$(cat "$dir/ADP1/online")" -eq 0 ]; then + switch_to_battery_mode + fi + exit 0 + ;; - *) ;; + *) ;; esac #infinite loop -while charge=$(cat "$dir"/capacity); do - if [ "$(cat "$dir"/status)" = "Charging" ]; then +while charge=$(cat "$battery_dir"/capacity); do + if [ "$(cat "$battery_dir"/status)" = "Charging" ]; then i=300 #default polling time, it's 5 minutes else case $charge in diff --git a/hypr/hyprland.conf b/hypr/hyprland.conf index 276d9b7..f975c3a 100644 --- a/hypr/hyprland.conf +++ b/hypr/hyprland.conf @@ -4,7 +4,7 @@ monitorv2 { mode = preferred position = auto scale = 1.5 - vrr = 2 + vrr = 1 bitdepth = 10 } @@ -294,10 +294,21 @@ workspace = special, on-created-empty:[float] foot #startup applications exec-once = systemctl --user import-environment DBUS_SESSION_BUS_ADDRESS WAYLAND_DISPLAY XDG_SESSION_TYPE XDG_CURRENT_DESKTOP XDG_SESSION_DESKTOP QT_QPA_PLATFORMTHEME GTK_THEME exec-once = dbus-update-activation-environment --systemd --all -exec-once = hypridle -exec-once = ssh-agent + +# misc +exec-once = systemctl --user start ssh-agent +exec-once = systemctl --user start ntfy_sub +exec-once = systemctl --user start workspace + +# hypr ecosystem exec-once = systemctl --user start hyprpolkitagent -exec-once = swaybg -i $HOME/.config/wall/1.png -m fill -exec-once = $hypr_dir/workspace focus -exec-once = $hypr_dir/battery -exec-once = $hypr_dir/themes +exec-once = systemctl --user start hypridle + +# power +exec-once = systemctl --user start power-mode@check +exec-once = systemctl --user start monitor-battery + +# UI +exec-once = systemctl --user start theme +exec-once = systemctl --user start set-background@1.png + diff --git a/hypr/hyprlock.conf b/hypr/hyprlock.conf index dd2bd80..08f0c7a 100644 --- a/hypr/hyprlock.conf +++ b/hypr/hyprlock.conf @@ -48,7 +48,6 @@ input-field { check_color = rgb(204, 136, 34) fail_color = rgb(204, 34, 34) fail_text = $FAIL ($ATTEMPTS) - fail_transition = 300 capslock_color = -1 numlock_color = -1 bothlock_color = -1 diff --git a/hypr/ntfy.png b/hypr/ntfy.png new file mode 100644 index 0000000..6b969a8 Binary files /dev/null and b/hypr/ntfy.png differ diff --git a/hypr/ntfy_sub b/hypr/ntfy_sub new file mode 100755 index 0000000..25d715c --- /dev/null +++ b/hypr/ntfy_sub @@ -0,0 +1,24 @@ +#!/bin/sh + +notify () { + notify-send -i "$icon_path" -e -h "string:x-canonical-private-synchronous:${0##*/}" "[$1] ${2}" "$3" +} + +env_file="${XDG_CONFIG_HOME:-$HOME/.config}/.env" +. "$env_file" + +ntfy_creds load + +token="$(printf 'Basic %s' "$(printf ':%s' "$NTFY_TOKEN" | base64)" | base64 | tr -d '=')" +icon_path="$(dirname "$0")/ntfy.png" + +trap "ntfy_creds unload" EXIT +trap "ntfy_creds unload; exit 1" INT HUP + +websocat --no-close "wss://${NTFY_URL#https://}/$NTFY_TOPIC_LISTEN/ws?auth=$token" | while IFS= read -r line; do + title=$(printf '%s' "$line" | sed -nE 's|.*,"title":"([^"]*)",.*|\1|p') + topic=$(printf '%s' "$line" | sed -nE 's|.*,"topic":"([^"]*)",?.*|\1|p') + message=$(printf '%s' "$line" | sed -nE 's|.*,"message":"([^"]*)",.*|\1|p') + printf '%s' "$line" | grep -q '"open"' && notify "NTFY" "Listening" "$topic" + [ -z "$message" ] || notify "$topic" "${title:-NO TITLE}" "$message" +done diff --git a/hypr/virt-monitor b/hypr/virt-monitor index 72f6947..170c706 100755 --- a/hypr/virt-monitor +++ b/hypr/virt-monitor @@ -19,7 +19,7 @@ load() { ip r # start sunshine - sunshine > /dev/null + sunshine >/dev/null } unload() { diff --git a/hypr/workspace b/hypr/workspace index c47c36b..3e9df0e 100755 --- a/hypr/workspace +++ b/hypr/workspace @@ -46,7 +46,7 @@ case $1 in ;; focus) #shows the workspace number as notification whenever u switch workspaces and also handles the dual monitor setup on the fly(perfect for laptop users) - socat - "UNIX-CONNECT:$XDG_RUNTIME_DIR/hypr/$HYPRLAND_INSTANCE_SIGNATURE/.socket2.sock" | while read -r line; do + socat -u "UNIX-CONNECT:$XDG_RUNTIME_DIR/hypr/$HYPRLAND_INSTANCE_SIGNATURE/.socket2.sock" - | while read -r line; do printf "%s" "$line" | grep -qE "monitoraddedv2.*HEADLESS" && continue printf "%s" "$line" | grep -q "monitoraddedv2" && handle_it "$line" #recent workspace switcher diff --git a/mimeapps.list b/mimeapps.list index 72915d0..93f119d 100644 --- a/mimeapps.list +++ b/mimeapps.list @@ -1,14 +1,14 @@ [Default Applications] inode/directory=pcmanfm.desktop -image/jpeg=nsxiv.desktop +image/jpeg=org.xfce.ristretto.desktop application/pdf=firefox.desktop text/html=firefox.desktop x-scheme-handler/http=firefox.desktop x-scheme-handler/https=firefox.desktop x-scheme-handler/about=firefox.desktop x-scheme-handler/unknown=firefox.desktop -image/png=nsxiv.desktop -image/webp=nsxiv.desktop +image/png=org.xfce.ristretto.desktop +image/webp=org.xfce.ristretto.desktop plain/text=nvim.desktop text/x-python=nvim.desktop text/english=nvim.deskop @@ -41,10 +41,11 @@ application/x-bittorrent=torrent.desktop x-scheme-handler/magnet=torrent.desktop hoppscotch=hoppscotch-handler.desktop audio/flac=mpv.desktop +application/octet-stream=nvim.desktop [Added Associations] video/x-matroska=mpv.desktop; -application/octet-stream=mpv.desktop;firefox.desktop; +application/octet-stream=nvim.desktop;mpv.desktop;firefox.desktop; video/vnd.radgamettools.bink=mpv.desktop; x-scheme-handler/mailto=firefox.desktop; x-scheme-handler/http=firefox.desktop diff --git a/nvim/lazy-lock.json b/nvim/lazy-lock.json index 37bffbd..0295949 100644 --- a/nvim/lazy-lock.json +++ b/nvim/lazy-lock.json @@ -1,5 +1,5 @@ { - "LuaSnip": { "branch": "master", "commit": "a62e1083a3cfe8b6b206e7d3d33a51091df25357" }, + "LuaSnip": { "branch": "master", "commit": "0abc8f390b278c3b4aabc4c004ac8a088b65cf24" }, "cmp-buffer": { "branch": "main", "commit": "b74fab3656eea9de20a9b8116afa3cfc4ec09657" }, "cmp-cmdline": { "branch": "main", "commit": "d126061b624e0af6c3a556428712dd4d4194ec6d" }, "cmp-nvim-lsp": { "branch": "main", "commit": "cbc7b02bb99fae35cb42f514762b89b5126651ef" }, @@ -9,18 +9,18 @@ "friendly-snippets": { "branch": "main", "commit": "6cd7280adead7f586db6fccbd15d2cac7e2188b9" }, "lazy.nvim": { "branch": "main", "commit": "306a05526ada86a7b30af95c5cc81ffba93fef97" }, "lualine.nvim": { "branch": "master", "commit": "131a558e13f9f28b15cd235557150ccb23f89286" }, - "mason-lspconfig.nvim": { "branch": "main", "commit": "0c2823e0418f3d9230ff8b201c976e84de1cb401" }, - "mason.nvim": { "branch": "main", "commit": "cb8445f8ce85d957416c106b780efd51c6298f89" }, + "mason-lspconfig.nvim": { "branch": "main", "commit": "7b01e2974a47d489bb92f47a41e4c0088ea8f86e" }, + "mason.nvim": { "branch": "main", "commit": "cbf8d285e1462dd24acf3507817be2bbcb035919" }, "monokai-pro.nvim": { "branch": "main", "commit": "8ba1fea7774e7c522b006091a9adb32b5cef95b9" }, - "nvim-autopairs": { "branch": "master", "commit": "59bce2eef357189c3305e25bc6dd2d138c1683f5" }, + "nvim-autopairs": { "branch": "master", "commit": "7b9923abad60b903ece7c52940e1321d39eccc79" }, "nvim-cmp": { "branch": "main", "commit": "a1d504892f2bc56c2e79b65c6faded2fd21f3eca" }, "nvim-colorizer.lua": { "branch": "master", "commit": "a065833f35a3a7cc3ef137ac88b5381da2ba302e" }, - "nvim-dap": { "branch": "master", "commit": "45a69eba683a2c448dd9ecfc4de89511f0646b5f" }, + "nvim-dap": { "branch": "master", "commit": "531771530d4f82ad2d21e436e3cc052d68d7aebb" }, "nvim-dap-python": { "branch": "master", "commit": "1808458eba2b18f178f990e01376941a42c7f93b" }, - "nvim-lspconfig": { "branch": "master", "commit": "31026a13eefb20681124706a79fc1df6bf11ab27" }, + "nvim-lspconfig": { "branch": "master", "commit": "deb0df61b2d6691e745b16a42755e10ad38218e9" }, "nvim-parinfer": { "branch": "master", "commit": "3968e669d9f02589aa311d33cb475b16b27c5fbb" }, "nvim-treesitter": { "branch": "master", "commit": "cf12346a3414fa1b06af75c79faebe7f76df080a" }, "packer.nvim": { "branch": "master", "commit": "ea0cc3c59f67c440c5ff0bbe4fb9420f4350b9a3" }, "plenary.nvim": { "branch": "master", "commit": "74b06c6c75e4eeb3108ec01852001636d85a932b" }, - "telescope.nvim": { "branch": "master", "commit": "ec009610d5d259ec59a6edf0219ef3f7ee4732e5" } + "telescope.nvim": { "branch": "master", "commit": "7d324792b7943e4aa16ad007212e6acc6f9fe335" } } diff --git a/systemd/user/graphical-session-pre.target.wants/xdg-user-dirs.service b/systemd/user/graphical-session-pre.target.wants/xdg-user-dirs.service new file mode 120000 index 0000000..457b4d4 --- /dev/null +++ b/systemd/user/graphical-session-pre.target.wants/xdg-user-dirs.service @@ -0,0 +1 @@ +/usr/lib/systemd/user/xdg-user-dirs.service \ No newline at end of file diff --git a/systemd/user/monitor-battery.service b/systemd/user/monitor-battery.service new file mode 100644 index 0000000..e2bf7c7 --- /dev/null +++ b/systemd/user/monitor-battery.service @@ -0,0 +1,9 @@ +[Unit] +Description=Monitors the battery Power and State. + +[Service] +Type=simple +ExecStart=%h/.config/hypr/battery +Restart=on-failure +RestartSec=5 + diff --git a/systemd/user/ntfy_sub.service b/systemd/user/ntfy_sub.service new file mode 100644 index 0000000..731225c --- /dev/null +++ b/systemd/user/ntfy_sub.service @@ -0,0 +1,8 @@ +[Unit] +Description=Ntfy Subscribe Notifications + +[Service] +Type=simple +ExecStart=%h/.config/hypr/ntfy_sub +Restart=on-failure +RestartSec=5 diff --git a/systemd/user/power-mode@.service b/systemd/user/power-mode@.service index 2889e23..7c820f2 100644 --- a/systemd/user/power-mode@.service +++ b/systemd/user/power-mode@.service @@ -3,4 +3,4 @@ Description=Power Mode (%i) [Service] Type=oneshot -ExecStart=/home/tanveer/.config/hypr/battery %i +ExecStart=%h/.config/hypr/battery %i diff --git a/systemd/user/set-background@.service b/systemd/user/set-background@.service new file mode 100644 index 0000000..490c187 --- /dev/null +++ b/systemd/user/set-background@.service @@ -0,0 +1,8 @@ +[Unit] +Description=Set Background (%i) + +[Service] +Type=simple +ExecStartPre=-/usr/bin/pkill -x swaybg +ExecStart=/usr/sbin/swaybg -i %h/.config/wall/%i -m fill +Restart=on-failure diff --git a/systemd/user/theme.service b/systemd/user/theme.service new file mode 100644 index 0000000..096230d --- /dev/null +++ b/systemd/user/theme.service @@ -0,0 +1,6 @@ +[Unit] +Description=Set GTK Theme + +[Service] +Type=oneshot +ExecStart=%h/.config/hypr/themes diff --git a/systemd/user/workspace.service b/systemd/user/workspace.service new file mode 100644 index 0000000..b6e4170 --- /dev/null +++ b/systemd/user/workspace.service @@ -0,0 +1,9 @@ +[Unit] +Description=Monitors current Workspace + +[Service] +Type=simple +ExecStart=%h/.config/hypr/workspace focus +Restart=on-failure +RestartSec=5 +