Improve wayland configs

This commit is contained in:
Tobias Reisinger 2023-06-30 20:47:01 +02:00
parent 35f4e0c88f
commit ceea1c316a
Signed by: serguzim
GPG key ID: 13AD60C237A28DFE
18 changed files with 549 additions and 41 deletions

View file

@ -5,7 +5,7 @@ _systemctl () {
} }
_dasel () { _dasel () {
dasel -f "$HOME/.config/autostart.toml" -r toml "${@}" dasel -f "$HOME/.config/autostart.toml" -r toml -w plain "${@}"
} }
_list () { _list () {
@ -45,6 +45,10 @@ _autostart_manage_info () {
_echo_table "${autostart_units[@]}" | column -t -s$'\t' --table-columns 'Unit,Enabled?,Active?' _echo_table "${autostart_units[@]}" | column -t -s$'\t' --table-columns 'Unit,Enabled?,Active?'
} }
_autostart_manage_log () {
journalctl --user -fu "autostart@$1.service"
}
_autostart_manage_enable_all () { _autostart_manage_enable_all () {
autostart_units=() autostart_units=()
while IFS='' read -r line while IFS='' read -r line
@ -82,6 +86,29 @@ _autostart_manage_exec () {
bash -c "$cmd" bash -c "$cmd"
} }
_autostart_run_graphical () {
start-audio pipewire
wait-for-service "network-online.target"
if ! pgrep -x keepassxc
then
if pass
then
(pass keepass | head -n 1 | keepassxc --pw-stdin ~/sync/passwords.kdbx) &
fi
fi
autoinstall graphical
autostart-manage run
}
_autostart_run_wayland () {
_autostart_run_graphical
killall -SIGUSR2 waybar
}
_autostart_run_xorg () { _autostart_run_xorg () {
feh --bg-fill "$XDG_PICTURES_DIR/wallpaper/active_wallpaper" feh --bg-fill "$XDG_PICTURES_DIR/wallpaper/active_wallpaper"
@ -93,24 +120,7 @@ _autostart_run_xorg () {
xsetroot -cursor_name left_ptr xsetroot -cursor_name left_ptr
xrdb "$HOME/.Xresources" xrdb "$HOME/.Xresources"
#pkill sxhkd; sxhkd & _autostart_run_graphical
#pgrep -x xcompmgr > /dev/null || xcompmgr -cnfFn -D3 &
start-audio pipewire
wait-for-service "network-online.target"
if ! pgrep -x keepassxc
then
pass x
if [ $? -eq 0 ]
then
(pass keepass | head -n 1 | keepassxc --pw-stdin ~/sync/passwords.kdbx) &
fi
fi
autoinstall graphical
autostart-manage run
} }
case $1 in case $1 in
@ -120,11 +130,13 @@ case $1 in
enable) _systemctl "$2" add-wants autostart.target ;; enable) _systemctl "$2" add-wants autostart.target ;;
disable) _systemctl "$2" disable ;; disable) _systemctl "$2" disable ;;
restart) _systemctl "${2:-*}" restart;; restart) _systemctl "${2:-*}" restart;;
log) _autostart_manage_log "$2";;
start) _systemctl "${2:-*}" start;; start) _systemctl "${2:-*}" start;;
status) _systemctl "${2:-*}" status ;; status) _systemctl "${2:-*}" status ;;
stop) _systemctl "${2:-*}" stop ;; stop) _systemctl "${2:-*}" stop ;;
run) systemctl --user start autostart.target ;; run) systemctl --user start autostart.target ;;
run-xorg) _autostart_run_xorg ;; run-xorg) _autostart_run_xorg ;;
run-wayland) _autostart_run_wayland ;;
exec) _autostart_manage_exec "$2" ;; exec) _autostart_manage_exec "$2" ;;
*) echo "'$1' is not valid" ;; *) echo "'$1' is not valid" ;;
esac esac

View file

@ -2,7 +2,7 @@
set -e set -e
edit_dir_base="$HOME/.cache/edit/" edit_dir_base="$XDG_RUNTIME_DIR/edit/"
_pre_checks() { _pre_checks() {
if [ -z "$EDITOR" ]; then if [ -z "$EDITOR" ]; then

View file

@ -15,11 +15,15 @@ xcompmgr = 'xcompmgr -cnfFn -D3'
[portalo] [portalo]
ckb-next = 'ckb-next --background' ckb-next = 'ckb-next --background'
conky-archlinux-updates = 'conky --config="$HOME/.config/conky/archlinux-updates.conf"' conky-clock = ''
conky-system = ''
hyprland-handler = '$XDG_CONFIG_HOME/hypr/handler.sh'
polkit = '/usr/lib/polkit-gnome/polkit-gnome-authentication-agent-1' polkit = '/usr/lib/polkit-gnome/polkit-gnome-authentication-agent-1'
qbittorrent = 'flatpak run org.qbittorrent.qBittorrent' qbittorrent = 'flatpak run org.qbittorrent.qBittorrent'
signal = 'flatpak run org.signal.Signal' signal = 'flatpak run org.signal.Signal'
solaar = 'solaar --window hide' solaar = 'solaar --window hide'
steam = 'flatpak run com.valvesoftware.Steam -silent' steam = 'flatpak run com.valvesoftware.Steam -silent'
sxhkd = 'sxhkd "$HOME/.config/sxhkd/portalo"' sxhkd = ''
thunderbird = 'thunderbird' thunderbird = 'thunderbird'
swww = 'swww init --no-daemon'
waybar = 'waybar'

View file

@ -36,8 +36,8 @@ export MOAR="--style=dracula"
export PASSWORD_STORE_GENERATED_LENGTH='64' export PASSWORD_STORE_GENERATED_LENGTH='64'
export PS1='\$ ' export PS1='\$ '
#export QT_QPA_PLATFORM="wayland;xcb" export QT_QPA_PLATFORM="wayland;xcb"
export QT_QPA_PLATFORM="xcb" #export QT_QPA_PLATFORM="xcb"
export QT_QPA_PLATFORMTHEME="qt5ct" export QT_QPA_PLATFORMTHEME="qt5ct"
#export SDL_VIDEODRIVER="wayland" #export SDL_VIDEODRIVER="wayland"

View file

@ -8,6 +8,7 @@
./common.nix ./common.nix
./graphical.nix ./graphical.nix
./nvim.nix ./nvim.nix
./wayland.nix
]; ];
home.packages = with pkgs; [ home.packages = with pkgs; [

View file

@ -0,0 +1,9 @@
{ config, pkgs, ... }:
{
# Packages that should be installed to the user profile.
home.packages = with pkgs; [
grim # needed for screenshots/flameshot
swww
];
}

85
.config/hypr/base.conf Normal file
View file

@ -0,0 +1,85 @@
source = ~/.config/hypr/dracula.conf
# See https://wiki.hyprland.org/Configuring/Monitors/
#monitor=,preferred,auto,auto
# See https://wiki.hyprland.org/Configuring/Keywords/ for more
# Execute your favorite apps at launch
# exec-once = waybar & hyprpaper & firefox
# Some default env vars.
env = XCURSOR_SIZE,24
# For all categories, see https://wiki.hyprland.org/Configuring/Variables/
input {
kb_layout = de
kb_variant =
kb_model =
kb_options =
kb_rules =
follow_mouse = 1
accel_profile = flat
touchpad {
natural_scroll = no
}
sensitivity = 0 # -1.0 - 1.0, 0 means no modification.
}
general {
# See https://wiki.hyprland.org/Configuring/Variables/ for more
gaps_in = 3
gaps_out = 6
border_size = 1
no_cursor_warps = true
layout = dwindle
}
decoration {
# See https://wiki.hyprland.org/Configuring/Variables/ for more
rounding = 3
blur = yes
blur_size = 3
blur_passes = 1
blur_new_optimizations = on
}
animations {
enabled = yes
# Some default animations, see https://wiki.hyprland.org/Configuring/Animations/ for more
bezier = myBezier, 0.05, 0.9, 0.1, 1.05
animation = windows, 1, 7, myBezier
animation = windowsOut, 1, 7, default, popin 80%
animation = border, 1, 10, default
animation = borderangle, 1, 8, default
animation = fade, 1, 7, default
animation = workspaces, 1, 6, default
}
dwindle {
# See https://wiki.hyprland.org/Configuring/Dwindle-Layout/ for more
pseudotile = yes # master switch for pseudotiling. Enabling is bound to mainMod + P in the keybinds section below
preserve_split = yes # you probably want this
no_gaps_when_only = yes # whether to apply gaps when there is only one window
}
master {
# See https://wiki.hyprland.org/Configuring/Master-Layout/ for more
new_is_master = true
}
source = ~/.config/hypr/binds.conf
source = ~/.config/hypr/rules.conf
exec-once = autostart-manage run-wayland

54
.config/hypr/binds.conf Normal file
View file

@ -0,0 +1,54 @@
$mainMod = SUPER
# Example binds, see https://wiki.hyprland.org/Configuring/Binds/ for more
bind = $mainMod, return, exec, $TERMINAL
bind = $mainMod, Q, killactive,
bind = $mainMod, M, exit,
bind = $mainMod, E, exec, dolphin
bind = $mainMod, V, togglefloating,
bind = $mainMod, D, exec, j4-dmenu-desktop --dmenu="$DMENU"
bind = $mainMod, P, pseudo, # dwindle
bind = $mainMod, J, togglesplit, # dwindle
bind = $mainMod SHIFT, R, exec, autostart-manage run-wayland
# Move focus with mainMod + arrow keys
bind = $mainMod, left, movefocus, l
bind = $mainMod, right, movefocus, r
bind = $mainMod, up, movefocus, u
bind = $mainMod, down, movefocus, d
# Switch workspaces with mainMod + [0-9]
bind = $mainMod, 1, workspace, $ws01
bind = $mainMod, 2, workspace, $ws02
bind = $mainMod, 3, workspace, $ws03
bind = $mainMod, 4, workspace, $ws04
bind = $mainMod, 5, workspace, $ws05
bind = $mainMod, 6, workspace, $ws06
bind = $mainMod, 7, workspace, $ws07
bind = $mainMod, 8, workspace, $ws08
bind = $mainMod, 9, workspace, $ws09
bind = $mainMod, 0, workspace, $ws10
# Move active window to a workspace with mainMod + SHIFT + [0-9]
bind = $mainMod SHIFT, 1, movetoworkspacesilent, $ws01
bind = $mainMod SHIFT, 2, movetoworkspacesilent, $ws02
bind = $mainMod SHIFT, 3, movetoworkspacesilent, $ws03
bind = $mainMod SHIFT, 4, movetoworkspacesilent, $ws04
bind = $mainMod SHIFT, 5, movetoworkspacesilent, $ws05
bind = $mainMod SHIFT, 6, movetoworkspacesilent, $ws06
bind = $mainMod SHIFT, 7, movetoworkspacesilent, $ws07
bind = $mainMod SHIFT, 8, movetoworkspacesilent, $ws08
bind = $mainMod SHIFT, 9, movetoworkspacesilent, $ws09
bind = $mainMod SHIFT, 0, movetoworkspacesilent, $ws10
bind = $mainMod, dead_circumflex, workspace, $ws_focus
bind = $mainMod SHIFT, dead_circumflex, movetoworkspacesilent, $ws_focus
# Scroll through existing workspaces with mainMod + scroll
bind = $mainMod, mouse_down, workspace, e+1
bind = $mainMod, mouse_up, workspace, e-1
# Move/resize windows with mainMod + LMB/RMB and dragging
bindm = $mainMod, mouse:272, movewindow
bindm = $mainMod, mouse:273, resizewindow

View file

@ -0,0 +1,18 @@
$ws01 = name:[01]
$ws02 = name:[02]
$ws03 = name:[03]
$ws04 = name:[04]
$ws05 = name:[05]
$ws06 = name:[06]
$ws07 = name:[07]
$ws08 = name:[08]
$ws09 = name:[09]
$ws10 = name:[10]
$ws_web = $ws01
$ws_focus = $ws07
$ws_media = $ws08
$ws_voip = $ws09
$ws_msg = $ws10
$ws_steam = $ws_media

18
.config/hypr/dracula.conf Normal file
View file

@ -0,0 +1,18 @@
# dracula/hyprland
general {
col.active_border = rgb(bd93f9)
col.inactive_border = rgba(44475aaa)
col.group_border = rgba(282a36dd)
col.group_border_active = rgb(bd93f9)
}
decoration {
col.shadow = rgba(1E202966)
# suggested shadow setting
drop_shadow = yes
shadow_range = 60
shadow_offset = 1 2
shadow_render_power = 3
shadow_scale = 0.97
}
#windowrulev2 = bordercolor rgb(ff5555),xwayland:1 # check if window is xwayland

23
.config/hypr/handler.sh Executable file
View file

@ -0,0 +1,23 @@
#!/usr/bin/env nix-shell
#!nix-shell -i sh -p socat jq
ws_media="[08]"
ws_voip="[09]"
_handler_check_ws_media_empty() {
has_zero_windows=$(hyprctl workspaces -j | jq ".[] | select(.name == \"$ws_media\") | .windows == 0")
if [ "$has_zero_windows" == "true" ]; then
hyprctl dispatch workspace "$ws_voip"
fi
}
handle() {
case $1 in
movewindow*) _handler_check_ws_media_empty "$1" ;;
closewindow*) _handler_check_ws_media_empty "$1" ;;
esac
}
socat -U - "UNIX-CONNECT:/tmp/hypr/$HYPRLAND_INSTANCE_SIGNATURE/.socket2.sock" | while read -r line; do handle "$line"; done

View file

@ -0,0 +1,21 @@
source = ~/.config/hypr/defaults.conf
$mon1 = DP-1
$mon2 = HDMI-A-1
workspace=$ws01, monitor:$mon1, default:true
workspace=$ws02, monitor:$mon1
workspace=$ws03, monitor:$mon1
workspace=$ws04, monitor:$mon1
workspace=$ws05, monitor:$mon1
workspace=$ws06, monitor:$mon1
workspace=$ws07, monitor:$mon1
workspace=$ws08, monitor:$mon2
workspace=$ws09, monitor:$mon2, default:true
workspace=$ws10, monitor:$mon2
monitor = $mon1,2560x1440@144,1920x0,auto
monitor = $mon2,1920x1080@60,0x0,auto
source = ~/.config/hypr/base.conf

24
.config/hypr/rules.conf Normal file
View file

@ -0,0 +1,24 @@
### Workspace rules
windowrulev2 = workspace $ws_web,class:(qutebrowser)
windowrulev2 = workspace $ws_web,class:(firefox)
windowrulev2 = workspace $ws_focus,class:^(jetbrains-)
windowrulev2 = workspace $ws_media,class:(Chromium)
windowrulev2 = workspace $ws_media,class:(FreeTube)
windowrulev2 = workspace $ws_voip,class:(discord)
windowrulev2 = workspace $ws_voip,class:(Element)
windowrulev2 = workspace $ws_voip,class:(TeamSpeak 3)
windowrulev2 = workspace $ws_msg,class:(thunderbird)
windowrulev2 = workspace $ws_msg,class:(Signal)
### Specific rules
#windowrulev2 = workspace $ws_steam silent,class:(steam) # Moves menues too :/
#windowrulev2 = noinitialfocus,class:(steam) # No focus on menues :/
windowrulev2 = fullscreen,class:(FreeTube)

12
.config/waybar/colors.css Normal file
View file

@ -0,0 +1,12 @@
@define-color background-darker #1E1F29;
@define-color background #282a36;
@define-color selection #44475a;
@define-color foreground #f8f8f2;
@define-color comment #6272a4;
@define-color cyan #8be9fd;
@define-color green #50fa7b;
@define-color orange #ffb86c;
@define-color pink #ff79c6;
@define-color purple #bd93f9;
@define-color red #ff5555;
@define-color yellow #f1fa8c;

80
.config/waybar/config Normal file
View file

@ -0,0 +1,80 @@
{
"layer": "top",
"position": "bottom",
"height": 24,
"spacing": 4,
"modules-left": [
"wlr/workspaces"
],
"modules-center": [
],
"modules-right": [
"network",
"cpu",
"temperature",
"memory",
"custom/pacman",
"idle_inhibitor",
"custom/weather",
"clock",
"tray"
],
"wlr/workspaces": {
"on-click": "activate",
"all-outputs": true,
"sort-by-number": true,
"persistent_workspaces": {
"01": [],
"02": [],
"03": [],
"04": [],
"05": [],
"06": [],
"07": [],
"08": [],
"09": [],
"10": []
}
},
"sway/workspaces": {
"disable-scroll": true,
"all-outputs": true,
"format": "{name}",
"persistent_workspaces": {
"01": [],
"02": [],
"03": [],
"04": [],
"05": [],
"06": [],
"07": [],
"08": [],
"09": [],
"10": []
}
},
"hyprland/window": {
"max-length": 128
},
"clock": {
"format": "{:%Y-%m-%d %H:%M:%S}",
"tooltip-format": "<big>{:%Y %B}</big>\n<tt><small>{calendar}</small></tt>"
},
"tray": {
"spacing": 4
},
"custom/pacman": {
"format": " {}",
"interval": 3600,
"exec": "checkupdates | wc -l",
"on-click": "alacritty -e 'archlinux-update'; pkill -SIGRTMIN+8 waybar",
"signal": 8
},
"custom/weather": {
"exec": "~/.config/waybar/wttr.py",
"return-type": "json",
"format": "{}",
"tooltip": true,
"interval": 1200
}
}

36
.config/waybar/style.css Normal file
View file

@ -0,0 +1,36 @@
@import url("./colors.css");
* {
border: none;
border-radius: 0;
font-family: Iosevka;
font-size: 11pt;
min-height: 0;
}
window#waybar {
opacity: 1;
background: @background-darker;
color: @foreground;
border-bottom: 2px solid @background;
}
#workspaces button {
padding: 0 10px;
background: @background;
color: @foreground;
}
#workspaces button:hover {
box-shadow: inherit;
text-shadow: inherit;
background-image: linear-gradient(0deg, @selection, @background-darker);
}
#workspaces button.active,
#workspaces button.focused,
#workspaces button.visible {
background-image: linear-gradient(0deg, @purple, @selection);
}
#taskbar button.active {
background-image: linear-gradient(0deg, @pruple, @background-darker);
}
#clock {
padding: 0 4px;
background: @background;
}

115
.config/waybar/wttr.py Executable file
View file

@ -0,0 +1,115 @@
#!/usr/bin/env nix-shell
#!nix-shell -i python -p python3 python3Packages.requests
import json
import requests
from datetime import datetime
WEATHER_CODES = {
'113': '☀️',
'116': '⛅️',
'119': '☁️',
'122': '☁️',
'143': '🌫',
'176': '🌦',
'179': '🌧',
'182': '🌧',
'185': '🌧',
'200': '',
'227': '🌨',
'230': '❄️',
'248': '🌫',
'260': '🌫',
'263': '🌦',
'266': '🌦',
'281': '🌧',
'284': '🌧',
'293': '🌦',
'296': '🌦',
'299': '🌧',
'302': '🌧',
'305': '🌧',
'308': '🌧',
'311': '🌧',
'314': '🌧',
'317': '🌧',
'320': '🌨',
'323': '🌨',
'326': '🌨',
'329': '❄️',
'332': '❄️',
'335': '❄️',
'338': '❄️',
'350': '🌧',
'353': '🌦',
'356': '🌧',
'359': '🌧',
'362': '🌧',
'365': '🌧',
'368': '🌨',
'371': '❄️',
'374': '🌧',
'377': '🌧',
'386': '',
'389': '🌩',
'392': '',
'395': '❄️'
}
data = {}
weather = requests.get("https://wttr.in/?format=j1").json()
def format_time(time):
return time.replace("00", "").zfill(2)
def format_temp(temp):
return (hour['FeelsLikeC']+"°").ljust(3)
def format_chances(hour):
chances = {
"chanceoffog": "Fog",
"chanceoffrost": "Frost",
"chanceofovercast": "Overcast",
"chanceofrain": "Rain",
"chanceofsnow": "Snow",
"chanceofsunshine": "Sunshine",
"chanceofthunder": "Thunder",
"chanceofwindy": "Wind"
}
conditions = []
for event in chances.keys():
if int(hour[event]) > 0:
conditions.append(chances[event]+" "+hour[event]+"%")
return ", ".join(conditions)
data['text'] = WEATHER_CODES[weather['current_condition'][0]['weatherCode']] + \
" "+weather['current_condition'][0]['FeelsLikeC']+"°"
data['tooltip'] = f"<b>{weather['current_condition'][0]['weatherDesc'][0]['value']} {weather['current_condition'][0]['temp_C']}°</b>\n"
data['tooltip'] += f"Feels like: {weather['current_condition'][0]['FeelsLikeC']}°\n"
data['tooltip'] += f"Wind: {weather['current_condition'][0]['windspeedKmph']}Km/h\n"
data['tooltip'] += f"Humidity: {weather['current_condition'][0]['humidity']}%\n"
for i, day in enumerate(weather['weather']):
data['tooltip'] += f"\n<b>"
if i == 0:
data['tooltip'] += "Today, "
if i == 1:
data['tooltip'] += "Tomorrow, "
data['tooltip'] += f"{day['date']}</b>\n"
data['tooltip'] += f"⬆️ {day['maxtempC']}° ⬇️ {day['mintempC']}° "
data['tooltip'] += f"🌅 {day['astronomy'][0]['sunrise']} 🌇 {day['astronomy'][0]['sunset']}\n"
for hour in day['hourly']:
if i == 0:
if int(format_time(hour['time'])) < datetime.now().hour-2:
continue
data['tooltip'] += f"{format_time(hour['time'])} {WEATHER_CODES[hour['weatherCode']]} {format_temp(hour['FeelsLikeC'])} {hour['weatherDesc'][0]['value']}, {format_chances(hour)}\n"
print(json.dumps(data))

View file

@ -7,7 +7,3 @@ then
export SSH_AUTH_SOCK="$ssh_sock" export SSH_AUTH_SOCK="$ssh_sock"
gpgconf --launch gpg-agent >/dev/null gpgconf --launch gpg-agent >/dev/null
fi fi
if [ -z "${DISPLAY}" ] && [ "${XDG_VTNR}" -le 2 ] && [ -n "${AUTOSTART_DISPLAY}" ]; then
exec $AUTOSTART_DISPLAY
fi