From bf6a91943d2c5852025ed1d1aadb30d83edf0354 Mon Sep 17 00:00:00 2001 From: Ryan Schanzenbacher Date: Wed, 17 May 2023 00:21:45 -0400 Subject: [PATCH] Added personal channel, starting to add more dotfiles --- channels.scm | 8 +- home-config/home-configuration.scm | 4 +- home-config/sway/config | 325 ++++++++++++++++++++++++++ home-config/waybar/config | 116 +++++++++ home-config/waybar/modules/spotify.sh | 19 ++ home-config/waybar/modules/storage.sh | 25 ++ home-config/waybar/modules/weather.sh | 77 ++++++ home-config/waybar/style.css | 77 ++++++ 8 files changed, 646 insertions(+), 5 deletions(-) create mode 100644 home-config/sway/config create mode 100644 home-config/waybar/config create mode 100755 home-config/waybar/modules/spotify.sh create mode 100755 home-config/waybar/modules/storage.sh create mode 100755 home-config/waybar/modules/weather.sh create mode 100644 home-config/waybar/style.css diff --git a/channels.scm b/channels.scm index 4321cc3..f29c0c7 100644 --- a/channels.scm +++ b/channels.scm @@ -20,8 +20,8 @@ "897c1a470da759236cc11798f4e0a5f7d4d59fbc" (openpgp-fingerprint "2A39 3FFF 68F4 EF7A 3D29 12AF 6F51 20A0 22FB B2D5")))) - ;(channel - ; (name 'ryan-home-services) - ; (url "https://git.ryanserver.home.arpa") - ; (branch "main")) + (channel + (name 'ryan-home-services) + (url "https://git.ryanserver.home.arpa/ryan77627/ryan-home-services") + (branch "main")) ) diff --git a/home-config/home-configuration.scm b/home-config/home-configuration.scm index 9a5953d..51fdcd6 100644 --- a/home-config/home-configuration.scm +++ b/home-config/home-configuration.scm @@ -90,6 +90,8 @@ "bash_profile"))))) (service home-xdg-configuration-files-service-type `(("nvim/init.vim" ,(local-file "nvim/config/init.vim")) - ("nvim/after/ftplugin/markdown/custom.vim" ,(local-file "nvim/config/after/ftplugin/markdown/custom.vim")) )) + ("nvim/after/ftplugin/markdown/custom.vim" ,(local-file "nvim/config/after/ftplugin/markdown/custom.vim")) + ("sway" ,(local-file "sway" #:recursive? #t)) + ("waybar" ,(local-file "waybar" #:recursive? #t)) )) (service home-files-service-type `((".local/share/nvim/site/autoload/plug.vim" ,(local-file "nvim/plugin-manager/plug.vim")) ))))) diff --git a/home-config/sway/config b/home-config/sway/config new file mode 100644 index 0000000..28953b8 --- /dev/null +++ b/home-config/sway/config @@ -0,0 +1,325 @@ +# Ryan's config for sway +# +# Dependencies: +# waybar +# fuzzel +# light (with proper udev setting for backlight control) +# alacritty +# swaylock-effects +# swayidle +# dejavu-fonts-ttf +# nerd-fonts-otf +# noto-fonts-cjk +# mako / libnotify +# grim / slurp / wl-clipboard +# swaybg +# pipewire / pipewire-pulse / pipewire-jack / wireplumber +# blueman +# spotifyd +# syslog-ng +# OPTIONAL: wdisplays (monitor layout) +# ... + +### Variables +exec sh ~/.profile + +# Load up the user session dbus +exec dbus-daemon --session --address=unix:path=$XDG_RUNTIME_DIR/bus + +# +# Logo key. Use Mod1 for Alt. +set $mod Mod4 +# Home row direction keys, like vim +set $left h +set $down j +set $up k +set $right l +# Your preferred terminal emulator +set $term alacritty +# Your preferred application launcher +# Note: pass the final command to swaymsg so that the resulting window can be opened +# on the original workspace that the command was run on. +#set $menu bemenu-run --no-exec | xargs swaymsg exec -- +set $menu fuzzel --width=35 --font='Hack:weight=bold:size=12' --background-color='282a36fa' --selection-color='3d4460fa' --line-height=20 --border-radius=20 + +# Set lock screen settings +set $lock 'swaylock --screenshots --clock --indicator --grace 3 --fade-in 1 --effect-blur 7x5 --effect-greyscale' +# Same as above but no grace period +set $lock_now 'swaylock --screenshots --clock --indicator --fade-in 1 --effect-blur 7x5 --effect-greyscale' +### Output configuration +# +# Default wallpaper (more resolutions are available in /usr/share/backgrounds/sway/) +output * bg ~/Pictures/Wallpapers/mountains.jpg fill +# +# Example configuration: +# +# output HDMI-A-1 resolution 1920x1080 position 1920,0 +# +# You can get the names of your outputs by running: swaymsg -t get_outputs (moved to ~/.config/sway/monitors) + +include ~/.config/sway/monitors + +#output eDP-1 mode 1920x1080@60.008Hz pos 1920 590 +#output HDMI-A-1 mode 1920x1080@74.972Hz pos 0 0 + +### Idle configuration +# +# Example configuration: +# +exec swayidle -w \ + timeout 300 $lock \ + timeout 600 'swaymsg "output * dpms off"' resume 'swaymsg "output * dpms on"' \ + before-sleep 'swaylock -f -c 000000' + +# Winkey+L lock key combo +bindsym $mod+l exec $lock_now +# +#Winkey+Shift+L to lock then go to sleep. zzz must run with no passwd +bindsym $mod+Shift+l exec 'swaylock --screenshots --clock --indicator --effect-blur 7x5 --effect-greyscale & sleep 0.5; doas zzz' + +# This will lock your screen after 300 seconds of inactivity, then turn off +# your displays after another 300 seconds, and turn your screens back on when +# resumed. It will also lock your screen before your computer goes to sleep. + +### Input configuration +# +# Example configuration: +# +# input "2:14:SynPS/2_Synaptics_TouchPad" { +# dwt enabled +# tap enabled +# natural_scroll enabled +# middle_emulation enabled +# } +# +# You can get the names of your inputs by running: swaymsg -t get_inputs +# Read `man 5 sway-input` for more information about this section. + +gaps inner 10 + +### Key bindings +# +# Basics: +# + # Start a terminal + bindsym $mod+Return exec $term + + # Kill focused window + bindsym $mod+Shift+q kill + + # Start your launcher + bindsym $mod+d exec $menu + + # Drag floating windows by holding down $mod and left mouse button. + # Resize them with right mouse button + $mod. + # Despite the name, also works for non-floating windows. + # Change normal to inverse to use left mouse button for resizing and right + # mouse button for dragging. + floating_modifier $mod normal + + # Reload the configuration file + bindsym $mod+Shift+c reload + #Restart your session + bindsym $mod+Shift+r restart + + # Exit sway (logs you out of your Wayland session) + bindsym $mod+Shift+e exec swaynag -t warning -m 'You pressed the exit shortcut. Do you really want to exit sway? This will end your Wayland session.' -B 'Yes, exit sway' 'swaymsg exit' +# +# Moving around: +# + # Move your focus around + bindsym $mod+$left focus left + bindsym $mod+$down focus down + bindsym $mod+$up focus up + #bindsym $mod+$right focus right + # Or use $mod+[up|down|left|right] + bindsym $mod+Left focus left + bindsym $mod+Down focus down + bindsym $mod+Up focus up + bindsym $mod+Right focus right + + # Move the focused window with the same, but add Shift + bindsym $mod+Shift+$left move left + bindsym $mod+Shift+$down move down + bindsym $mod+Shift+$up move up + #bindsym $mod+Shift+$right move right + # Ditto, with arrow keys + bindsym $mod+Shift+Left move left + bindsym $mod+Shift+Down move down + bindsym $mod+Shift+Up move up + bindsym $mod+Shift+Right move right + + # Since I run more than one monitor most of the time, these let me move + # workspaces between physical screens + bindsym $mod+Control+Shift+Right move workspace to output right + bindsym $mod+Control+Shift+Left move workspace to output left + # Now I could do the same with up and down but I don't have any of those +# +# Workspaces: +# + # Switch to workspace + bindsym $mod+1 workspace number 1 + bindsym $mod+2 workspace number 2 + bindsym $mod+3 workspace number 3 + bindsym $mod+4 workspace number 4 + bindsym $mod+5 workspace number 5 + bindsym $mod+6 workspace number 6 + bindsym $mod+7 workspace number 7 + bindsym $mod+8 workspace number 8 + bindsym $mod+9 workspace number 9 + bindsym $mod+0 workspace number 10 + # Move focused container to workspace + bindsym $mod+Shift+1 move container to workspace number 1 + bindsym $mod+Shift+2 move container to workspace number 2 + bindsym $mod+Shift+3 move container to workspace number 3 + bindsym $mod+Shift+4 move container to workspace number 4 + bindsym $mod+Shift+5 move container to workspace number 5 + bindsym $mod+Shift+6 move container to workspace number 6 + bindsym $mod+Shift+7 move container to workspace number 7 + bindsym $mod+Shift+8 move container to workspace number 8 + bindsym $mod+Shift+9 move container to workspace number 9 + bindsym $mod+Shift+0 move container to workspace number 10 + # Note: workspaces can have any name you want, not just numbers. + # We just use 1-10 as the default. +# +# Layout stuff: +# + # You can "split" the current object of your focus with + # $mod+b or $mod+v, for horizontal and vertical splits + # respectively. + bindsym $mod+b splith + bindsym $mod+v splitv + + # Switch the current container between different layout styles + bindsym $mod+s layout stacking + bindsym $mod+w layout tabbed + bindsym $mod+e layout toggle split + + # Make the current focus fullscreen + bindsym $mod+f fullscreen + + # Toggle the current focus between tiling and floating mode + bindsym $mod+Shift+space floating toggle + + # Swap focus between the tiling area and the floating area + bindsym $mod+space focus mode_toggle + + # Move focus to the parent container + bindsym $mod+a focus parent + + bindsym $mod+Ctrl+Right focus sibling next + +# +# Misc. button bindings +# + # Some custom keybinds for various keys on my laptop + bindsym XF86MonBrightnessUp exec light -A 10 + bindsym XF86MonBrightnessDown exec light -U 10 + +# +# Scratchpad: +# + # Sway has a "scratchpad", which is a bag of holding for windows. + # You can send windows there and get them back later. + + # Move the currently focused window to the scratchpad + bindsym $mod+Shift+minus move scratchpad + + # Show the next scratchpad window or hide the focused scratchpad window. + # If there are multiple scratchpad windows, this command cycles through them. + bindsym $mod+minus scratchpad show +# +# Resizing containers: +# +mode "resize" { + # left will shrink the containers width + # right will grow the containers width + # up will shrink the containers height + # down will grow the containers height + bindsym $left resize shrink width 10px + bindsym $down resize grow height 10px + bindsym $up resize shrink height 10px + bindsym $right resize grow width 10px + + # Ditto, with arrow keys + bindsym Left resize shrink width 10px + bindsym Down resize grow height 10px + bindsym Up resize shrink height 10px + bindsym Right resize grow width 10px + + # Return to default mode + bindsym Return mode "default" + bindsym Escape mode "default" +} +bindsym $mod+r mode "resize" + +# +# Status Bar: +# +# Read `man 5 sway-bar` for more information about this section. +#bar { +# position top +# +# # When the status_command prints a new line to stdout, swaybar updates. +# # The default just shows the current date and time. +# status_command while date +'%Y-%m-%d %I:%M:%S %p'; do sleep 1; done +# +# colors { +# statusline #ffffff +# background #323232 +# inactive_workspace #32323200 #32323200 #5c5c5c +# } +#} + +bar { + swaybar_command waybar +} + +exec hash dbus-update-activation-environment 2>/dev/null && dbus-update-activation-environment DISPLAY WAYLAND_DISPLAY SWAYSOCK + +# Numlock on startup +input * xkb_numlock enabled + +# Audio Server +#exec pipewire +#exec wireplumber +#exec pipewire-pulse + +# Bluetooth +exec blueman-applet + +# Spotifyd +#exec spotifyd + +# Notification controls +exec mako +bindsym $mod+n exec makoctl dismiss +bindsym $mod+Shift+n exec makoctl dismiss -a + +# Flameshot position fix and autostart +#exec QT_QPA_PLATFORM=wayland flameshot +#for_window [app_id="flameshot"] border pixel 0, floating enable, fullscreen disable, move absolute position 0 0 + +# Screenshots to clipboard +bindsym $mod+Shift+S exec grim -g "$(slurp)" - | wl-copy -t image/png +bindsym $mod+Print exec grim - | wl-copy -t image/png +#bindsym $mod+Ctrl+Shift+S exec grim -g "$(slurp)" $(echo "$HOME/Pictures/Screenshot_$(date +'%Y%m%d')_$(date +'%H%M%S').png") +bindsym $mod+Ctrl+Print exec grim -o $(swaymsg -t get_outputs | jq -r '.[] | select(.focused) | .name') - | wl-copy -t image/png + +# Zathura notes window resize +for_window [app_id="org.pwmt.zathura" title="^.*notes.pdf$"] resize set width 775 + +# Syncthing start +exec syncthing serve --no-browser + +# Force various windows to be floating +# Firefox PIP YT Player +for_window [app_id="firefox-default" title="^Picture-in-Picture$"] floating enable, resize set 578 326, border none, sticky enable +# Duo 2FA +for_window [app_id="firefox-default" title="^Activate Security Key — Mozilla Firefox$"] floating enable +for_window [app_id="firefox-default" title="^Nightly — Sharing Indicator$"] floating enable, resize set 18 52, border none, move position center, move y 0px +# Qjackctl +for_window [app_id="qjackctl"] floating enable +# Weather Window +for_window [app_id="ala-wttr"] border none, floating enable, resize set 740 712 +include /etc/sway/config.d/* diff --git a/home-config/waybar/config b/home-config/waybar/config new file mode 100644 index 0000000..10e27c7 --- /dev/null +++ b/home-config/waybar/config @@ -0,0 +1,116 @@ +{ + "layer": "bottom", + "position": "top", + "height": 30, + + "modules-left": ["sway/workspaces", "sway/mode"], + "modules-center": ["sway/window"], + "modules-right": ["tray", "custom/spotify", "custom/weather", "custom/mail", "custom/storage", "backlight", "pulseaudio", "network", "idle_inhibitor", "battery", "clock"], + "sway/mode": { + "format": " {}" + }, + "sway/workspaces": { + "format": "{name}", + "disable-scroll": true + }, + "sway/window": { + "max-length": 80, + "tooltip": false + }, + "clock": { + "format": "{:%a %d %b %H:%M}", + "tooltip": false + }, + "battery": { + "format": "{capacity}% {icon}", + "format-alt": "{time} {icon}", + "format-icons": ["", "", "", "", ""], + "format-charging": "{capacity}% ", + "interval": 30, + "states": { + "warning": 25, + "critical": 10 + }, + "tooltip": false, + "bat":"BAT1" + }, + "network": { + "format-alt": "{icon}", + "format": "{ipaddr}/{cidr} {icon}", + "format-alt-click": "click-right", + "format-icons": { + "wifi": ["", "" ,""], + "ethernet": [""], + "disconnected": ["睊"] + }, + "on-click": "alacritty -e iwctl", + "tooltip": false + }, + "pulseaudio": { + "format-alt": "{icon}", + "format": "{volume} {icon}", + "format-alt-click": "click-right", + "format-muted": "", + "format-icons": { + "phone": [" ", " ", " ", " "], + "default": ["", "", "", ""] + }, + "scroll-step": 1, + "on-click": "pavucontrol", + "tooltip": false + }, + "custom/spotify": { + "interval": 2, + "return-type": "json", + "exec": "~/.config/waybar/modules/spotify.sh", + "exec-if": "pgrep spotifyd", + "escape": true, + "on-click": "~/.config/waybar/modules/spotify-play-pause.sh play-pause" + }, + "custom/storage": { + "format-alt": "{} ", + "format": "{percentage}% ", + "format-alt-click": "click-right", + "return-type": "json", + "interval": 60, + "exec": "~/.config/waybar/modules/storage.sh" + }, + "backlight": { + "format-alt": "{icon}", + "format": "{percent}% {icon}", + "format-alt-click": "click-right", + "format-icons": ["", ""], + "on-scroll-down": "light -A 1", + "on-scroll-up": "light -U 1" + }, + "custom/weather": { + "format-alt": "{}", + "format": "{alt}: {}", + "format-alt-click": "click-right", + "interval": 1800, + "return-type": "json", + "on-click": "alacritty --class ala-wttr --hold -e curl https://v2.wttr.in", + "exec": "~/.config/waybar/modules/weather.sh", + "exec-if": "ping wttr.in -c1" + }, + "idle_inhibitor": { + "format": "{icon}", + "format-icons": { + "activated": "", + "deactivated": "" + }, + "tooltip": false + }, + "custom/mail": { + "format": "", + "format-alt": "{alt} ", + "format-alt-click": "click-right", + "interval": 60, + "return-type": "json", + "exec": "~/.config/waybar/modules/mail.py", + "tooltip": false + }, + "tray": { + "icon-size": 18 + } +} diff --git a/home-config/waybar/modules/spotify.sh b/home-config/waybar/modules/spotify.sh new file mode 100755 index 0000000..a75136c --- /dev/null +++ b/home-config/waybar/modules/spotify.sh @@ -0,0 +1,19 @@ +#!/bin/sh + +class=$(playerctl metadata --player=spotifyd --format '{{lc(status)}}') +icon="" + +if [[ $class == "playing" ]]; then + info=$(playerctl metadata --player=spotifyd --format '{{artist}} - {{title}}') + if [[ ${#info} > 40 ]]; then + info=$(echo $info | cut -c1-40)"..." + fi + text=$info" "$icon +elif [[ $class == "paused" ]]; then + text=$icon +elif [[ $class == "stopped" ]]; then + text="" +fi + +echo -e "{\"text\":\""$text"\", \"class\":\""$class"\"}" + diff --git a/home-config/waybar/modules/storage.sh b/home-config/waybar/modules/storage.sh new file mode 100755 index 0000000..90cc3dc --- /dev/null +++ b/home-config/waybar/modules/storage.sh @@ -0,0 +1,25 @@ +#!/bin/sh + +mount="/" +warning=20 +critical=10 + +df -h -P -l "$mount" | awk -v warning=$warning -v critical=$critical ' +/\/.*/ { + text=$4 + tooltip="Filesystem: "$1"\rSize: "$2"\rUsed: "$3"\rAvail: "$4"\rUse%: "$5"\rMounted on: "$6 + use=$5 + exit 0 +} +END { + class="" + gsub(/%$/,"",use) + if ((100 - use) < critical) { + class="critical" + } else if ((100 - use) < warning) { + class="warning" + } + print "{\"text\":\""text"\", \"percentage\":"use",\"tooltip\":\""tooltip"\", \"class\":\""class"\"}" +} +' + diff --git a/home-config/waybar/modules/weather.sh b/home-config/waybar/modules/weather.sh new file mode 100755 index 0000000..01faffc --- /dev/null +++ b/home-config/waybar/modules/weather.sh @@ -0,0 +1,77 @@ +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]}"\"}" diff --git a/home-config/waybar/style.css b/home-config/waybar/style.css new file mode 100644 index 0000000..f785881 --- /dev/null +++ b/home-config/waybar/style.css @@ -0,0 +1,77 @@ +* { + border: none; + border-radius: 0; + font-family: Sans; + font-size: 15px; + box-shadow: none; + text-shadow: none; + transition-duration: 0s; + color: white; +} + +#waybar { + background-color:rgba(0,0,0,0.25); + color: white; +} + +window { + color: rgba(217, 216, 216, 1); + background: rgba(35, 31, 32, 0.00); +} + +window#waybar.solo { + color: rgba(217, 216, 216, 1); + background: rgba(35, 31, 32, 0.85); +} + +#workspaces { + margin: 0 5px; +} + +#workspaces button { + padding: 0 5px; + color: rgba(217, 216, 216, 0.4); +} + +#workspaces button.visible { + color: rgba(217, 216, 216, 1); +} + +#workspaces button.focused { + border-top: 3px solid rgba(217, 216, 216, 1); + border-bottom: 3px solid rgba(217, 216, 216, 0); +} + +#workspaces button.urgent { + color: rgba(238, 46, 36, 1); +} + +#mode, #battery, #cpu, #memory, #network, #pulseaudio, #idle_inhibitor, #backlight, #custom-storage, #custom-spotify, #custom-weather, #custom-mail { + margin: 0px 6px 0px 10px; + min-width: 25px; +} + +#clock { + margin: 0px 16px 0px 10px; + min-width: 140px; +} + +#battery.warning { + color: rgba(255, 210, 4, 1); +} + +#battery.critical { + color: rgba(238, 46, 36, 1); +} + +#battery.charging { + color: rgba(217, 216, 216, 1); +} + +#custom-storage.warning { + color: rgba(255, 210, 4, 1); +} + +#custom-storage.critical { + color: rgba(238, 46, 36, 1); +}