From 5f3e3c14569b9fef4a0e14ffbbc9ea2a8e93d0d3 Mon Sep 17 00:00:00 2001 From: Klesh Wong Date: Sat, 30 Jul 2022 10:15:33 +0800 Subject: [PATCH] refactor: extract autostart to a independent script --- gui/awesome.sh | 1 + gui/awesome/autostart | 30 ++++++++++++++++++++++++++++++ gui/awesome/rc.lua | 15 +-------------- 3 files changed, 32 insertions(+), 14 deletions(-) create mode 100755 gui/awesome/autostart diff --git a/gui/awesome.sh b/gui/awesome.sh index 8419d59..3882dc7 100755 --- a/gui/awesome.sh +++ b/gui/awesome.sh @@ -66,5 +66,6 @@ EOT # configuration lnsf "$DIR/awesome/rc.lua" "$XDG_CONFIG_HOME/awesome/rc.lua" +lnsf "$DIR/awesome/autostart" "$XDG_CONFIG_HOME/awesome/autostart" lnsf "$DIR/rofi/config.rasi" "$XDG_CONFIG_HOME/rofi/config.rasi" lnsf "$DIR/rofi/catppuccin.rasi" "$XDG_CONFIG_HOME/rofi/catppuccin.rasi" diff --git a/gui/awesome/autostart b/gui/awesome/autostart new file mode 100755 index 0000000..025b68a --- /dev/null +++ b/gui/awesome/autostart @@ -0,0 +1,30 @@ +#!/bin/sh + +# startup apps +! /bin/pgrep nextcloud && nextcloud & +! /bin/pgrep flameshot && flameshot & +! /bin/pgrep nm-applet && nm-applet & +! /bin/pgrep copyq && copyq & +! /bin/pgrep -f "lua virtcam.lua" && cd ~/dotfiles/gui/virtcam && lua virtcam.lua & + +# input method +ibus-daemon -drx + +# turn bluetooth power on +bluetoothctl power on + +# export X variable for cronjob to send notification +echo DBUS_SESSION_BUS_ADDRESS=$DBUS_SESSION_BUS_ADDRESS > ~/.cron.env +echo DISPLAY=$DISPLAY >> ~/.cron.env + +# adjust brightness in battery mode +grep -F 0 /sys/class/power_supply/ACAD/online && sudo light -S 30 + +# prioritize hdmi output +HDMI_SINK=$(pactl list short sinks | awk '{print $2}' | grep hdmi) +if [ -n "$HDMI_SINK" ]; then + pactl set-default-sink "$HDMI_SINK" +fi + +# fix pulseaudio echo-cancel side effect +pactl set-source-volume @DEFAULT_SOURCE@ 100% diff --git a/gui/awesome/rc.lua b/gui/awesome/rc.lua index f282cda..7260616 100644 --- a/gui/awesome/rc.lua +++ b/gui/awesome/rc.lua @@ -872,17 +872,4 @@ client.connect_signal("unfocus", function(c) --c.border_width = 0 end) --- Autostart -awful.spawn.with_shell("! /bin/pgrep nextcloud && nextcloud") -awful.spawn.with_shell("ibus-daemon -drx") -awful.spawn.with_shell("flameshot") ---awful.spawn.with_shell("blueman-applet") -awful.spawn.with_shell("nm-applet") -awful.spawn.with_shell("copyq") -awful.spawn.with_shell("bluetoothctl power on") --- store session variables for crontab -awful.spawn.with_shell("echo DBUS_SESSION_BUS_ADDRESS=$DBUS_SESSION_BUS_ADDRESS > ~/.cron.env") -awful.spawn.with_shell("echo DISPLAY=$DISPLAY >> ~/.cron.env") -awful.spawn.with_shell("grep -F 0 /sys/class/power_supply/ACAD/online && sudo light -S 30") -awful.spawn.with_shell("cd ~/dotfiles/gui/virtcam && lua virtcam.lua") --- }}} +awful.spawn.with_shell("~/.config/awesome/autostart")