-
Notifications
You must be signed in to change notification settings - Fork 0
/
.xsession
executable file
·82 lines (79 loc) · 2.37 KB
/
.xsession
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#!/bin/bash
# without these cron, etc cant get pulseaudio volume, etc
export DISPLAY=":0"
export PULSE_RUNTIME_PATH="/run/user/1000/pulse/"
#top bar
barupdate() {
#vars
BAT=$(cat /sys/class/power_supply/BAT0/capacity)
ISONLINE=$(networkctl status -n 0 --no-pager | grep -oP '(?<=State: ).*?(?=$)')
SINK=$(pacmd list-sinks | awk '/\* index:/{ print $3 }')
STATUS=$(cat /sys/class/power_supply/BAT0/status)
VOLUME=$(pactl get-sink-volume "$SINK" | grep -oP "[0-9]{1,3}%" | head -n 1)
BATIND=""
BATLABEL="bat:"
VOLLABEL="vol:"
if [ "$STATUS" == "Charging" ]; then
BATIND="*"
elif [ "$STATUS" == "Discharging" ]; then
BATIND="%"
elif [ "$STATUS" == "Not charging" ]; then
BATIND="?"
fi
if [ "$BAT" == "100" ]; then
BATLABEL=""
BATIND=""
BAT="charged"
fi
if [[ "$(pactl get-sink-mute "$SINK")" =~ "yes" ]]; then
VOLLABEL=""
VOLUME="muted"
fi
if [ "$ISONLINE" == "routable" ] ; then
NETSTAT="connected"
else
NETSTAT="no networks"
fi
if mullvad status | grep -q '^Connected'; then
VPN="[vpn] "
else
VPN=""
fi
# cursor setting is required bc this script gets called from cron
xsetroot -cursor_name left_ptr -name " $VPN$(date +%H:%M) | $(date +%a | tr '[A-Z]' '[a-z]') $(date +%d/%m/%Y) | $NETSTAT $VOLLABEL$VOLUME $BATLABEL$BAT$BATIND "
}
startup() {
#keymap
setxkbmap de
#autostart
clipmenud &
ssh-agent &
blueberry-tray &
networkd-dispatcher &
/usr/lib/mate-polkit/polkit-mate-authentication-agent-1 & # polkit
start-pulseaudio-x11 &
/usr/bin/nextcloud --background &
picom &
dunst &
eval $(gnome-keyring-daemon --start) # keyring
export SSH_AUTH_SOCK # https://wiki.archlinux.org/title/GNOME/Keyring#xinitrc
xset -dpms # disable dpms
xset s off # disable screensaver
redshift &
xautolock -time 10 -locker "/usr/bin/pactl set-sink-mute 0 1; systemctl suspend" -detectsleep -notify 25 -notifier "notify-send --urgency=critical -t 5000 'suspending in 20s'" &
echo off > ~/.cache/dwmespresso.txt # see ~/.scripts/espresso
#wallpaper
hsetroot -solid "$(shuf -n 1 ~/.config/bgcolors)"
# set default sound card output
sudo -u nils pactl --server "unix:/run/user/1000/pulse/native" set-card-profile 0 output:analog-stereo+input:analog-stereo
# setup dwm bar
~/.xsession barupdate
#finally
exec ~/.scripts/startdwm
}
case $1 in
barupdate)
barupdate ;;
*)
startup ;;
esac