Adds config for hypr

This commit is contained in:
Michel Fedde 2025-02-12 10:11:30 +01:00
parent 6469f64213
commit 95f3e5a5d7
12 changed files with 762 additions and 0 deletions

View file

@ -0,0 +1,16 @@
# /* ---- 💫 https://github.com/JaKooLit 💫 ---- */ #
KooL's Hyprland-Dots
1.) Suggest not to rename any files in this folder. As this is connected and being sourced from hyprland.conf in ~/.config/hypr
2.) This folder, along with UserScripts folder will NOT be touch when running upgrade.sh
3.) However, if hyprland has a big change in settings, i.e., blur section is moved into another group, you should managed the change yourself.
4.) Guidance on the keybinds. Suggest NOT to assign a keybind which I set on the default Keybinds. Else will conflict. Once Hyprland decided to have a global keybinds, then I will adjust.
5.) If you think that the default keybinds SHOULD be adjusted, open an issue on my github page and present me a valid argument. Like conflicting to GLOBAL keybinds, etc etc etc.
I will update the Hyprland-Dots wiki for guidance. Make sure to check out changelogs as well

View file

@ -0,0 +1,25 @@
animations {
enabled = yes
bezier = wind, 0.05, 0.9, 0.1, 1.05
bezier = winIn, 0.1, 1.1, 0.1, 1.1
bezier = winOut, 0.3, -0.3, 0, 1
bezier = liner, 1, 1, 1, 1
bezier = overshot, 0.05, 0.9, 0.1, 1.05
bezier = smoothOut, 0.5, 0, 0.99, 0.99
bezier = smoothIn, 0.5, -0.5, 0.68, 1.5
animation = windows, 1, 6, wind, slide
animation = windowsIn, 1, 5, winIn, slide
animation = windowsOut, 1, 3, smoothOut, slide
animation = windowsMove, 1, 5, wind, slide
animation = border, 1, 1, liner
animation = borderangle, 1, 180, liner, loop #used by rainbow borders and rotating colors
animation = fade, 1, 3, smoothOut
animation = workspaces, 1, 5, overshot
# animations for -git or version >0.42.0
animation = workspacesIn, 1, 5, winIn, slide
animation = workspacesOut, 1, 5, winOut, slide
}

View file

@ -0,0 +1,47 @@
general {
border_size = 2
gaps_in = 6
gaps_out = 8
col.active_border = rgb(AE9B92)
col.inactive_border = rgb(806254)
}
decoration {
rounding = 3
active_opacity = 1.0
inactive_opacity = 0.9
fullscreen_opacity = 1.0
dim_inactive = true
dim_strength = 0.1
dim_special = 0.8
shadow {
enabled = true
range = 3
render_power = 1
color = rgb(AE9B92)
color_inactive = rgb(806254)
}
blur {
enabled = true
size = 6
passes = 2
ignore_opacity = true
new_optimizations = true
special = true
}
}
group {
col.border_active = rgb(E8E5E3)
groupbar {
col.active = rgb(4B4C52)
}
}

View file

@ -0,0 +1,36 @@
# Set your defaults here
env = EDITOR,nvim #default editor
#environment-variables
env = CLUTTER_BACKEND,wayland
env = GDK_BACKEND,wayland,x11
env = QT_AUTO_SCREEN_SCALE_FACTOR,1
env = QT_QPA_PLATFORM,wayland;xcb
env = QT_QPA_PLATFORMTHEME,qt5ct
env = QT_QPA_PLATFORMTHEME,qt6ct
env = QT_SCALE_FACTOR,1
env = QT_WAYLAND_DISABLE_WINDOWDECORATION,1
env = XDG_CURRENT_DESKTOP,Hyprland
env = XDG_SESSION_DESKTOP,Hyprland
env = XDG_SESSION_TYPE,wayland
# hyprland-qt-support
env = QT_QUICK_CONTROLS_STYLE,org.hyprland.style
# xwayland apps scale fix (useful if you are use monitor scaling)
# see https://wiki.hyprland.org/Configuring/XWayland/
# toolkit-specific scale
env = GDK_SCALE,1
# Bibata-Modern-Ice-Cursor
# NOTE! You must have the hyprcursor version to activate this.
# If you installed from 26-Dec-2024 and choose GTK theme, then you have it.
# https://wiki.hyprland.org/Hypr-Ecosystem/hyprcursor/
env = HYPRCURSOR_THEME,Bibata-Modern-Ice
env = HYPRCURSOR_SIZE,24
# firefox
env = MOZ_ENABLE_WAYLAND,1
# electron >28 apps (may help)
env = ELECTRON_OZONE_PLATFORM_HINT,auto

View file

@ -0,0 +1,109 @@
$mainMod = SUPER
# Default
$scriptsDir = $HOME/.config/hypr/scripts
$configs = $HOME/.config/hypr/configs
bind = $mainMod, Q, killactive,
bind = $mainMod SHIFT, Q, exec, $scriptsDir/KillActiveProcess.sh
# Special Keys / Hot Keys
bindel = , xf86audioraisevolume, exec, $scriptsDir/Volume.sh --inc # volume up
bindel = , xf86audiolowervolume, exec, $scriptsDir/Volume.sh --dec # volume down
bindl = , xf86AudioMicMute, exec, $scriptsDir/Volume.sh --toggle-mic # mic mute
bindl = , xf86audiomute, exec, $scriptsDir/Volume.sh --toggle # mute
bindl = , xf86Sleep, exec, systemctl suspend # sleep button
bindl = , xf86Rfkill, exec, $scriptsDir/AirplaneMode.sh # Airplane mode
# media controls using keyboards
bindl = , xf86AudioPlayPause, exec, $scriptsDir/MediaCtrl.sh --pause
bindl = , xf86AudioPause, exec, $scriptsDir/MediaCtrl.sh --pause
bindl = , xf86AudioPlay, exec, $scriptsDir/MediaCtrl.sh --pause
bindl = , xf86AudioNext, exec, $scriptsDir/MediaCtrl.sh --nxt
bindl = , xf86AudioPrev, exec, $scriptsDir/MediaCtrl.sh --prv
bindl = , xf86audiostop, exec, $scriptsDir/MediaCtrl.sh --stop
# Move focus with mainMod + LHKJ
bind = $mainMod, H, movefocus, l
bind = $mainMod, L, movefocus, r
bind = $mainMod, K, movefocus, u
bind = $mainMod, J, movefocus, d
# Move windows
bind = $mainMod SHIFT, H, movewindow, l
bind = $mainMod SHIFT, L, movewindow, r
bind = $mainMod SHIFT, K, movewindow, u
bind = $mainMod SHIFT, J, movewindow, d
# Container layouts
bind = $mainMod, E, togglesplit
bind = $mainMod, W, togglegroup
bind = $mainMod SHIFT, Space, togglefloating
bind = $mainMod SHIFT, Space, pin
# Workspaces
bind = $mainMod, code:10, workspace, 1
bind = $mainMod, code:11, workspace, 2
bind = $mainMod, code:12, workspace, 3
bind = $mainMod, code:13, workspace, 4
bind = $mainMod, code:14, workspace, 5
bind = $mainMod, code:15, workspace, 6
bind = $mainMod, code:16, workspace, 7
bind = $mainMod, code:17, workspace, 8
bind = $mainMod, code:18, workspace, 9
bind = $mainMod, code:19, workspace, 10
# Move active window to a workspace silently mainMod + CTRL [0-9]
bind = $mainMod CTRL, code:10, movetoworkspacesilent, 1
bind = $mainMod CTRL, code:11, movetoworkspacesilent, 2
bind = $mainMod CTRL, code:12, movetoworkspacesilent, 3
bind = $mainMod CTRL, code:13, movetoworkspacesilent, 4
bind = $mainMod CTRL, code:14, movetoworkspacesilent, 5
bind = $mainMod CTRL, code:15, movetoworkspacesilent, 6
bind = $mainMod CTRL, code:16, movetoworkspacesilent, 7
bind = $mainMod CTRL, code:17, movetoworkspacesilent, 8
bind = $mainMod CTRL, code:18, movetoworkspacesilent, 9
bind = $mainMod CTRL, code:19, movetoworkspacesilent, 10
bind = $mainMod CTRL, bracketleft, movetoworkspacesilent, -1 # brackets [ or ]
bind = $mainMod CTRL, bracketright, movetoworkspacesilent, +1
# Scroll through existing workspaces with mainMod + scroll
bind = $mainMod, mouse_down, workspace, e+1
bind = $mainMod, mouse_up, workspace, e-1
bind = $mainMod, bracketright, workspace, e+1
bind = $mainMod, bracketleft, workspace, e-1
# Move/resize windows with mainMod + LMB/RMB and dragging
bindm = $mainMod, mouse:272, movewindow
bindm = $mainMod, mouse:273, resizewindow
# Stuff
bind = $mainMod SHIFT, C, exec, $scriptsDir/Refresh.sh # Refresh waybar, swaync, rofi
bind = $mainMod SHIFT, E, exec, $scriptsDir/Wlogout.sh # power menu
bind = $mainMod, N, exec, $scriptsDir/LockScreen.sh # screen lock
bind = , Print, exec, $scriptsDir/ScreenShot.sh --area # screenshot (area)
bind = ALT, Print, exec, $scriptsDir/ScreenShot.sh --active # screenshot (active window only)
bind = $mainMod SHIFT, N, exec, swaync-client -t -sw # swayNC notification panel
bind = $mainMod SHIFT, A, movecurrentworkspacetomonitor, l
bind = $mainMod SHIFT, D, movecurrentworkspacetomonitor, r
bind = $mainMod, F, fullscreen, 0
bind = $mainMod SHIFT, F, fullscreen, 1
$mainMod = SUPER
$files = thunar
$term = kitty
$scriptsDir = $HOME/.config/hypr/scripts
# rofi App launcher
#bindr = $mainMod, $mainMod_L, exec, pkill rofi || rofi -show drun -modi drun,filebrowser,run,window # Super Key to Launch rofi menu
bind = $mainMod, Tab, exec, nwg-drawer
bind = ALT, Tab, exec, hyprswitch gui --mod-key alt --key tab
bind = $mainMod, Return, exec, $term #terminal
bind = $mainMod, T, exec, $files #file manager

View file

@ -0,0 +1,14 @@
# /* ---- 💫 https://github.com/JaKooLit 💫 ---- */ #
# Monitor Configuration
# See Hyprland wiki for more details
# https://wiki.hyprland.org/Configuring/Monitors/
# Configure your Display resolution, offset, scale and Monitors here, use `hyprctl monitors` to get the info.
$primary=DP-4
$secondary=DP-2
monitor=$primary, preferred, 0x0, 1
monitor=$secondary, preferred, auto-left, 1
exec=xrandr --output $primary --primary

View file

@ -0,0 +1,125 @@
# /* ---- 💫 https://github.com/JaKooLit 💫 ---- */ #
# User Settings
# This is where you put your own settings as this will not be touched during update
# if the upgrade.sh is used.
# refer to Hyprland wiki for more info https://wiki.hyprland.org/Configuring/Variables/
# NOTE: some settings are in ~/.config/hypr/UserConfigs/UserDecorAnimations.conf
dwindle {
pseudotile = yes
preserve_split = yes
special_scale_factor = 0.8
}
master {
new_status = master
new_on_top = 1
mfact = 0.5
}
general {
resize_on_border = true
layout = dwindle
}
input {
kb_layout = us
kb_variant =
kb_model =
kb_options =
kb_rules =
repeat_rate = 50
repeat_delay = 300
accel_profile = flat
sensitivity = 0 #mouse sensitivity
numlock_by_default = true
left_handed = false
follow_mouse = true
float_switch_override_focus = false
touchpad {
disable_while_typing = true
natural_scroll = false
clickfinger_behavior = false
middle_button_emulation = true
tap-to-click = true
drag_lock = false
}
# below for devices with touchdevice ie. touchscreen
touchdevice {
enabled = true
}
# below is for table see link above for proper variables
tablet {
transform = 0
left_handed = 0
}
}
device {
name = logitech-mx-ergo-1
accel_profile = adaptive
}
gestures {
workspace_swipe = true
workspace_swipe_fingers = 3
workspace_swipe_distance = 500
workspace_swipe_invert = true
workspace_swipe_min_speed_to_force = 30
workspace_swipe_cancel_ratio = 0.5
workspace_swipe_create_new = true
workspace_swipe_forever = true
#workspace_swipe_use_r = true #uncomment if wanted a forever create a new workspace with swipe right
}
misc {
disable_hyprland_logo = true
disable_splash_rendering = true
vfr = true
vrr = 2
mouse_move_enables_dpms = true
enable_swallow = true
swallow_regex = ^(kitty)$
focus_on_activate = false
initial_workspace_tracking = 0
middle_click_paste = false
}
#opengl {
# nvidia_anti_flicker = true
#}
binds {
workspace_back_and_forth = true
allow_workspace_cycles = true
pass_mouse_when_bound = false
}
#Could help when scaling and not pixelating
xwayland {
enabled = true
force_zero_scaling = true
}
# render section for Hyprland >= v0.42.0
render {
explicit_sync = 2
explicit_sync_kms = 2
direct_scanout = false
}
cursor {
sync_gsettings_theme = true
no_hardware_cursors = 2
enable_hyprcursor = true
warp_on_change_workspace = 2
no_warps = true
}

View file

@ -0,0 +1,35 @@
# /* ---- 💫 https://github.com/JaKooLit 💫 ---- */ #
#Commands & Apps to be executed at launch
$scriptsDir = $HOME/.config/hypr/scripts
$UserScripts = $HOME/.config/hypr/UserScripts
# wallpaper stuff / More wallpaper options below
exec-once = swww-daemon --format xrgb
# Startup
exec-once = dbus-update-activation-environment --systemd WAYLAND_DISPLAY XDG_CURRENT_DESKTOP
exec-once = systemctl --user import-environment WAYLAND_DISPLAY XDG_CURRENT_DESKTOP
# Polkit (Polkit Gnome / KDE)
exec-once = $scriptsDir/Polkit.sh
# starup apps
exec-once = waybar &
exec-once = nm-applet --indicator &
exec-once = swaync &
exec-once = ags &
exec-once = blueman-applet &
exec-once = kdeconnect-indicator &
# exec-once = sleep 5 && nwg-dock-hyprland -a start -f -nolauncher -x -i 30 -o "DP-4" &
# Starting hypridle to start hyprlock
exec-once = hypridle &
# Start pyprland daemon
exec-once = pypr &
exec-once = wl-paste --type text --watch cliphist store # Stores only text data
exec-once = wl-paste --type image --watch cliphist store # Stores only image data
exec-once = hyprswitch init --show-title --size-factor 5.5 --workspaces-per-row 5 &

View file

@ -0,0 +1,114 @@
# /* ---- 💫 https://github.com/JaKooLit 💫 ---- */ #
# See https://wiki.hyprland.org/Configuring/Window-Rules/ for more
#windowrule = noblur,gamescope
#windowrule = fullscreen,gamescope
#windowrule = workspace 6 silent,^(gamescope)$
# windowrule Position
windowrule = center,^(pavucontrol|org.pulseaudio.pavucontrol|com.saivert.pwvucontrol)
windowrule = center,^([Ww]hatsapp-for-linux)$
windowrule = center,^([Ff]erdium)$
# WINDOWRULE v2
# windowrule v2 - position
# windowrulev2 = center,floating:1 # warning, it cause even the menu to float and center.
windowrulev2 = center, class:([Tt]hunar), title:(File Operation Progress)
windowrulev2 = center, class:([Tt]hunar), title:(Confirm to replace files)
windowrulev2 = center, title:^(ROG Control)$
windowrulev2 = center, title:^(Keybindings)$
windowrulev2 = move 72% 7%,title:^(Picture-in-Picture)$
#windowrulev2 = move 72% 7%,title:^(Firefox)$
# windowrule v2 to avoid idle for fullscreen apps
windowrulev2 = idleinhibit fullscreen, class:^(*)$
windowrulev2 = idleinhibit fullscreen, title:^(*)$
windowrulev2 = idleinhibit fullscreen, fullscreen:1
# windowrule v2 move to workspace
windowrulev2 = workspace 1, class:^([Ff]irefox|org.mozilla.firefox|[Ff]irefox-esr)$
windowrulev2 = workspace 1, class:^([Mm]icrosoft-edge(-stable|-beta|-dev|-unstable)?)$
windowrulev2 = workspace 1, class:^([Gg]oogle-chrome(-beta|-dev|-unstable)?)$
windowrulev2 = workspace 1, class:^([Tt]horium-browser|[Cc]achy-browser)$
windowrulev2 = workspace 1, class:^(zen)$ # zen browser
windowrulev2 = workspace 2, class:^(kitty)$
windowrulev2 = workspace 3, class:^([Dd]iscord|[Ww]ebCord|[Vv]esktop)$
windowrulev2 = workspace 3, class:^([Bb]eeper)$
windowrulev2 = workspace 3, class:^([Ff]erdium)$
windowrulev2 = workspace 3, class:^([Ww]hatsapp-for-linux)$
windowrulev2 = workspace 3, class:^(teams-for-linux)$
windowrulev2 = workspace 4 silent, class:^([Ss]team)$
windowrulev2 = workspace 4, class:^([Ll]utris)$
windowrulev2 = workspace 4, class:^([Hh]eroic)$
windowrulev2 = workspace 5, class:^(com.github.th_ch.youtube_music)$
# windowrule v2 - float
windowrulev2 = float, class:^(org.kde.polkit-kde-authentication-agent-1)$
windowrulev2 = float, class:([Zz]oom|onedriver|onedriver-launcher)$
windowrulev2 = float, class:([Tt]hunar), title:(File Operation Progress)
windowrulev2 = float, class:([Tt]hunar), title:(Confirm to replace files)
windowrulev2 = float, class:(xdg-desktop-portal-gtk)
windowrulev2 = float, class:(org.gnome.Calculator), title:(Calculator)
windowrulev2 = float, class:(codium|codium-url-handler|VSCodium|code-oss), title:(Add Folder to Workspace)
windowrulev2 = float, class:(electron), title:(Add Folder to Workspace)
windowrulev2 = float, class:^([Rr]ofi)$
windowrulev2 = float, class:^(eog|org.gnome.Loupe)$ # image viewer
windowrulev2 = float, class:^(pavucontrol|org.pulseaudio.pavucontrol|com.saivert.pwvucontrol)$
windowrulev2 = float, class:^(nwg-look|qt5ct|qt6ct)$
windowrulev2 = float, class:^(mpv|com.github.rafostar.Clapper)$
windowrulev2 = float, class:^(nm-applet|nm-connection-editor|blueman-manager)$
windowrulev2 = float, class:^(gnome-system-monitor|org.gnome.SystemMonitor|io.missioncenter.MissionCenter)$ # system monitor
windowrulev2 = float, class:^([Yy]ad)$
windowrulev2 = float, class:^(wihotspot(-gui)?)$ # wifi hotspot
windowrulev2 = float, class:^(evince)$ # document viewer
windowrulev2 = float, class:^(file-roller|org.gnome.FileRoller)$ # archive manager
windowrulev2 = float, class:^([Bb]aobab|org.gnome.[Bb]aobab)$ # Disk usage analyzer
windowrulev2 = float, title:(Kvantum Manager)
windowrulev2 = float, class:^([Ss]team)$,title:^((?![Ss]team).*|[Ss]team [Ss]ettings)$
windowrulev2 = float, class:^([Qq]alculate-gtk)$
#windowrulev2 = float, class:^([Ww]hatsapp-for-linux)$
windowrulev2 = float, class:^([Ff]erdium)$
windowrulev2 = float, title:^(Picture-in-Picture)$
windowrulev2 = float, title:^(ROG Control)$
#windowrulev2 = float, title:^(Firefox)$
windowrulev2 = float, title:^(hyprgui)$
windowrulev2 = float, class:^(io.ente.auth)$
# windowrule v2 - size
windowrulev2 = size 70% 70%, class:^(gnome-system-monitor|org.gnome.SystemMonitor|io.missioncenter.MissionCenter)$
windowrulev2 = size 70% 70%, class:^(xdg-desktop-portal-gtk)$
windowrulev2 = size 60% 70%, title:(Kvantum Manager)
windowrulev2 = size 60% 70%, class:^(qt6ct)$
windowrulev2 = size 70% 70%, class:^(evince|wihotspot(-gui)?)$
windowrulev2 = size 60% 70%, class:^(file-roller|org.gnome.FileRoller)$
windowrulev2 = size 60% 70%, class:^([Ww]hatsapp-for-linux)$
windowrulev2 = size 60% 70%, class:^([Ff]erdium)$
windowrulev2 = size 60% 70%, title:^(ROG Control)$
#windowrulev2 = size 25% 25%, title:^(Picture-in-Picture)$
#windowrulev2 = size 25% 25%, title:^(Firefox)$
windowrulev2 = size 60% 70%, title:^(hyprgui)$
windowrulev2 = size 240px 450px, class:^(libresplit)$
windowrulev2 = size 500px 1000px, class:^(io.ente.auth)$
# windowrule v2 - pinning
windowrulev2 = pin,title:^(Picture-in-Picture)$
windowrulev2 = pin,class: ^(io.ente.auth)$
#windowrulev2 = pin,title:^(Firefox)$
# windowrule v2 - extras
windowrulev2 = keepaspectratio, title:^(Picture-in-Picture)$
#windowrulev2 = bordercolor rgb(EE4B55) rgb(880808), fullscreen:1
#windowrulev2 = bordercolor rgb(282737) rgb(1E1D2D), floating:1
#windowrulev2 = opacity 0.8 0.8, pinned:1
# LAYER RULES
#layerrule = unset,class:^([Rr]ofi)$
#layerrule = blur,class:^([Rr]ofi)$
#layerrule = ignorezero, <rofi>
#layerrule = ignorezero, overview
#layerrule = blur, overview

View file

@ -0,0 +1,16 @@
# /* ---- 💫 https://github.com/JaKooLit 💫 ---- */ #
# You can set workspace rules to achieve workspace-specific behaviors.
# For instance, you can define a workspace where all windows are drawn without borders or gaps.
# https://wiki.hyprland.org/Configuring/Workspace-Rules/
$primary=DP-4
$secondary=DP-2
workspace = 1, name:Browser, monitor:$secondary, default:true
workspace = 2, name:Terminal, monitor:$primary, default:true
workspace = 3, name:Discord,monitor:$secondary, default:true
workspace = 4, name:Gaming, monitor:$primary, default:true
workspace = 5, name:Music

138
.config/hypr/scripts/Weather.py Executable file
View file

@ -0,0 +1,138 @@
#!/usr/bin/env python3
# /* ---- 💫 https://github.com/JaKooLit 💫 ---- */ #
# weather using python
import subprocess
from pyquery import PyQuery # install using `pip install pyquery`
import json
import os
# original code https://gist.github.com/Surendrajat/ff3876fd2166dd86fb71180f4e9342d7
# weather icons
weather_icons = {
"sunnyDay": "󰖙",
"clearNight": "󰖔",
"cloudyFoggyDay": "",
"cloudyFoggyNight": "",
"rainyDay": "",
"rainyNight": "",
"snowyIcyDay": "",
"snowyIcyNight": "",
"severe": "",
"default": "",
}
# get location_id
# to get your own location_id, go to https://weather.com & search your location.
# once you choose your location, you can see the location_id in the URL(64 chars long hex string)
# like this: https://weather.com/en-PH/weather/today/l/bca47d1099e762a012b9a139c36f30a0b1e647f69c0c4ac28b537e7ae9c1c200
location_id = "bca47d1099e762a012b9a139c36f30a0b1e647f69c0c4ac28b537e7ae9c1c200" # TODO
# NOTE to change to deg F, change the URL to your preffered location after weather.com
# Default is English-Philippines with Busan, South Korea as location_id
# get html page
url = "https://weather.com/en-PH/weather/today/l/" + location_id
html_data = PyQuery(url=url)
# current temperature
temp = html_data("span[data-testid='TemperatureValue']").eq(0).text()
# print(temp)
# current status phrase
status = html_data("div[data-testid='wxPhrase']").text()
status = f"{status[:16]}.." if len(status) > 17 else status
# print(status)
# status code
status_code = html_data("#regionHeader").attr("class").split(" ")[2].split("-")[2]
# print(status_code)
# status icon
icon = (
weather_icons[status_code]
if status_code in weather_icons
else weather_icons["default"]
)
# print(icon)
# temperature feels like
temp_feel = html_data(
"div[data-testid='FeelsLikeSection'] > span > span[data-testid='TemperatureValue']"
).text()
temp_feel_text = f"Feels like {temp_feel}c"
# print(temp_feel_text)
# min-max temperature
temp_min = (
html_data("div[data-testid='wxData'] > span[data-testid='TemperatureValue']")
.eq(1)
.text()
)
temp_max = (
html_data("div[data-testid='wxData'] > span[data-testid='TemperatureValue']")
.eq(0)
.text()
)
temp_min_max = f"{temp_min}\t\t{temp_max}"
# print(temp_min_max)
# wind speed
wind_speed = html_data("span[data-testid='Wind']").text().split("\n")[1]
wind_text = f"{wind_speed}"
# print(wind_text)
# humidity
humidity = html_data("span[data-testid='PercentageValue']").text()
humidity_text = f"{humidity}"
# print(humidity_text)
# visibility
visbility = html_data("span[data-testid='VisibilityValue']").text()
visbility_text = f"{visbility}"
# print(visbility_text)
# air quality index
air_quality_index = html_data("text[data-testid='DonutChartValue']").text()
# print(air_quality_index)
# hourly rain prediction
prediction = html_data("section[aria-label='Hourly Forecast']")(
"div[data-testid='SegmentPrecipPercentage'] > span"
).text()
prediction = prediction.replace("Chance of Rain", "")
prediction = f"\n\n (hourly) {prediction}" if len(prediction) > 0 else prediction
# print(prediction)
# tooltip text
tooltip_text = str.format(
"\t\t{}\t\t\n{}\n{}\n{}\n\n{}\n{}\n{}{}",
f'<span size="xx-large">{temp}</span>',
f"<big> {icon}</big>",
f"<b>{status}</b>",
f"<small>{temp_feel_text}</small>",
f"<b>{temp_min_max}</b>",
f"{wind_text}\t{humidity_text}",
f"{visbility_text}\tAQI {air_quality_index}",
f"<i> {prediction}</i>",
)
# print waybar module data
out_data = {
"text": f"{icon} {temp}",
"alt": status,
"tooltip": tooltip_text,
"class": status_code,
}
print(json.dumps(out_data))
simple_weather =f"{icon} {status}\n" + \
f"{temp} ({temp_feel_text})\n" + \
f"{wind_text} \n" + \
f"{humidity_text} \n" + \
f"{visbility_text} AQI{air_quality_index}\n"
try:
with open(os.path.expanduser("~/.cache/.weather_cache"), "w") as file:
file.write(simple_weather)
except:
pass

87
.config/hypr/scripts/Weather.sh Executable file
View file

@ -0,0 +1,87 @@
#!/bin/bash
# /* ---- 💫 https://github.com/JaKooLit 💫 ---- */ ##
# weather info from wttr. https://github.com/chubin/wttr.in
# Remember to add city
city=
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/"$city"$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=""
;;
"fog" | "freezing fog")
condition=""
;;
"patchy rain possible" | "patchy light drizzle" | "light drizzle" | "patchy light rain" | "light rain" | "light rain shower" | "mist" | "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]}"\"}"
cached_weather="$temperature \n$condition ${weather[1]}"
echo -e $cached_weather > ~/.cache/.weather_cache