TheRepoClub-DotFiles/localbin/.local/bin/autostart
2023-08-21 23:26:25 +01:00

277 lines
5.5 KiB
Bash
Executable File

#!/usr/bin/env bash
#-*-coding:utf-8 -*-
#Auto updated?
# Yes
#File:
# autostart
#Author:
# The-Repo-Club [wayne6324@gmail.com]
#Github:
# https://github.com/The-Repo-Club/
#
#Created:
# Mon 22 November 2021, 03:15:54 PM [GMT+1]
#Modified:
# Mon 21 August 2023, 11:20:48 PM [GMT+1]
#
#Description:
# <Todo>
#
#Dependencies:
# <None>
#
if command -v /usr/lib/polkit-gnome/polkit-gnome-authentication-agent-1 &>/dev/null; then
if ! pgrep -f "/usr/lib/polkit-gnome/polkit-gnome-authentication-agent-1" >/dev/null; then
/usr/lib/polkit-gnome/polkit-gnome-authentication-agent-1 &
else
echo "polkit-gnome already Running"
fi
fi
if [[ $DESKTOP_SESSION == "i3" ]]; then
if command -v polybar &>/dev/null; then
if ! pgrep -f "polybar" >/dev/null; then
(
sleep 2s
if ! test -f "$HOME/.config/polybar/launch.sh"; then
echo "$HOME/.config/polybar/launch.sh could not be found"
else
exec "$HOME/.config/polybar/launch.sh"
fi
) &
else
echo "polybar already Running"
fi
else
echo "polybar can not be found"
fi
if command -v i3-autolayout &>/dev/null; then
if ! pgrep -f "i3-autolayout" >/dev/null; then
(
sleep 2s
i3-autolayout autolayout
) &
else
echo "i3-autolayout already Running"
fi
else
echo "i3-autolayout can not be found"
fi
fi
if command -v xroot &>/dev/null; then
if ! pgrep -f "xroot" >/dev/null; then
if command -v xmenu_desktop &>/dev/null; then
if ! pgrep -f "xmenu_desktop" >/dev/null; then
(
sleep 2s
xroot -r xmenu_desktop
) &
else
echo "xmenu_desktop already Running"
fi
else
echo "xmenu_desktop can not be found"
fi
else
echo "xroot already Running"
fi
else
echo "xroot can not be found"
fi
if command -v clipmenu-daemon &>/dev/null; then
if ! pgrep -f "clipmenu-daemon" >/dev/null; then
(
sleep 2s
clipmenu-daemon
) &
else
echo "clipmenu-daemon already Running"
fi
else
echo "clipmenu-daemon can not be found"
fi
if command -v xcompmgr &>/dev/null; then
if ! pgrep -x "xcompmgr" >/dev/null; then
xcompmgr &
else
echo "xcompmgr already Running"
fi
else
echo "xcompmgr could not be found"
fi
################
## Tray Icons ##
################
if command -v ckb-next &>/dev/null; then
if ! pgrep -x "ckb-next" >/dev/null; then
(
sleep 2s
ckb-next --background
) &
else
echo "ckb-next already Running"
fi
else
echo "ckb-next could not be found"
fi
if command -v nm-applet &>/dev/null; then
if ! pgrep -x "nm-applet" >/dev/null; then
(
sleep 2s
nm-applet
) &
else
echo "nm-applet already Running"
fi
else
echo "nm-applet could not be found"
fi
if command -v blueman-applet &>/dev/null; then
if ! pgrep -x "blueman-applet" >/dev/null; then
(
sleep 2s
blueman-applet
) &
else
echo "blueman-applet already Running"
fi
else
echo "blueman-applet could not be found"
fi
if command -v touchpad-indicator &>/dev/null; then
if ! pgrep -f "touchpad-indicator" >/dev/null; then
(
sleep 2s
touchpad-indicator
) &
else
echo "touchpad-indicator already Running"
fi
else
echo "touchpad-indicator could not be found"
fi
if command -v cbatticon &>/dev/null; then
if ! pgrep -x "cbatticon" >/dev/null; then
(
sleep 2s
cbatticon
) &
else
echo "cbatticon already Running"
fi
else
echo "cbatticon could not be found"
fi
if command -v pasystray &>/dev/null; then
if ! pgrep -x "pasystray" >/dev/null; then
(
sleep 5s
pasystray
) &
else
echo "pasystray already Running"
fi
else
echo "pasystray could not be found"
fi
if command -v firewall-applet &>/dev/null; then
if ! pgrep -x "firewall-applet" >/dev/null; then
(
sleep 5s
firewall-applet
) &
else
echo "firewall-applet already Running"
fi
else
echo "firewall-applet could not be found"
fi
if command -v numlockx &>/dev/null; then
numlockx on &
else
echo "numlockx could not be found"
fi
####################
## Fix Background ##
####################
if command -v feh &>/dev/null; then
if ! test -f "$HOME/.fehbg"; then
echo "$HOME/.fehbg could not be found"
else
sh "$HOME/.fehbg"
(
sleep 2s
sh "$HOME/.fehbg"
) &
fi
else
echo "feh could not be found"
fi
###############
## Auto Lock ##
###############
if command -v xautolock &>/dev/null; then
# shellcheck disable=SC2155
if ! pgrep -x "xautolock" >/dev/null; then
(
sleep 2s
xautolock \
-time 15 -locker "multimonitorlock -l -- --time-str=%I:%M:%S %p" \
-detectsleep
) &
else
echo "xautolock already Running"
fi
else
echo "xautolock could not be found"
fi
if command -v xss-lock &>/dev/null; then
# shellcheck disable=SC2155
if ! pgrep -x "xss-lock" >/dev/null; then
(
sleep 2s
xss-lock -- multimonitorlock -l -- --time-str="%I:%M:%S %p"
) &
else
echo "xss-lock already Running"
fi
else
echo "xss-lock could not be found"
fi
################
## Other Junk ##
################
systemctl --user import-environment DISPLAY XAUTHORITY
if command -v dbus-update-activation-environment >/dev/null 2>&1; then
dbus-update-activation-environment DISPLAY XAUTHORITY
fi
# see https://wiki.archlinux.org/title/GNOME/Keyring#xinitrc
eval "$(/usr/bin/gnome-keyring-daemon --start)"
export SSH_AUTH_SOCK
# see https://github.com/NixOS/nixpkgs/issues/14966#issuecomment-520083836
mkdir -p "$HOME"/.local/share/keyrings