summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorSyndamia <kamen@syndamia.com>2022-08-04 17:41:27 +0300
committerSyndamia <kamen@syndamia.com>2022-08-04 17:41:27 +0300
commit80b4c81b618d4e75b301ac1dd5adfb47f91deca7 (patch)
treebc7d94935b273a1aa9b1a1b69c2bbc853c8a32e7 /scripts
parenta47706a5bd5ee5be16e3fe443b6008cac9ee741d (diff)
downloaddotfiles-80b4c81b618d4e75b301ac1dd5adfb47f91deca7.tar
dotfiles-80b4c81b618d4e75b301ac1dd5adfb47f91deca7.tar.gz
dotfiles-80b4c81b618d4e75b301ac1dd5adfb47f91deca7.zip
Moved a lot of stuff to a new folder called .a
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/app-mem.sh29
-rwxr-xr-xscripts/battery-status.sh57
-rwxr-xr-xscripts/dunst-toggler-applet.sh26
-rwxr-xr-xscripts/system/lock.sh118
-rwxr-xr-xscripts/system/on-wm-logout.sh8
-rwxr-xr-xscripts/system/on-wm-session.sh43
-rwxr-xr-xscripts/terminal.sh5
-rwxr-xr-xscripts/toggle-desktop.sh7
-rwxr-xr-xscripts/toggle-repo.sh7
9 files changed, 0 insertions, 300 deletions
diff --git a/scripts/app-mem.sh b/scripts/app-mem.sh
deleted file mode 100755
index 35384c9..0000000
--- a/scripts/app-mem.sh
+++ /dev/null
@@ -1,29 +0,0 @@
-#!/bin/bash
-
-# Huge thanks to https://askubuntu.com/a/549534/1085672 and https://www.zyxware.com/articles/4446/show-total-memory-usage-by-each-application-in-your-ubuntu-or-any-gnu-linux-system
-
-ps -A --sort -rss -o comm,pmem,rss | awk '
- NR == 1 { print; next }
- { a[$1] += $2; b[$1] += $3; }
- END {
- for (i in a) {
- size_in_bytes = b[i] * 1024
- split("B KB MB GB TB PB", unit)
- human_readable = 0
- if (size_in_bytes == 0) {
- human_readable = 0
- j = 0
- }
- else {
- for (j = 5; human_readable < 1; j--)
- human_readable = size_in_bytes / (2^(10*j))
- }
- printf "%-20s\t%s\t%.2f%s\t%s\n", i, a[i], human_readable, unit[j+2], b[i]
- }
- }
-' | awk 'NR>1' | sort -rnk4 | awk '
- BEGIN {printf "%-20s\t%%MEM\tSIZE\n", "COMMAND"}
- {
- printf "%-20s\t%s\t%s\n", $1, $2, $3
- }
-' | head -n 10
diff --git a/scripts/battery-status.sh b/scripts/battery-status.sh
deleted file mode 100755
index efbc2a2..0000000
--- a/scripts/battery-status.sh
+++ /dev/null
@@ -1,57 +0,0 @@
-#!/bin/bash
-
-if [[ "$(upower -i /org/freedesktop/UPower/devices/battery_BAT0 | grep native-path | awk '{print $2}')" == '(null)' ]]; then
- exit
-fi
-
-battery_notify () {
- # if battery percentage is equal to given one, if battery percentage inside /tmp/battery.tmp is not equal to given one and if power indicator is the given on
- if [ ${__bat_per} -eq $1 ] && ! grep -q $1 "/tmp/battery.tmp" && [[ ${__bat_power} = $2 ]]; then
- # Send notification and rewrite battery.tmp file with current percentage
- notify-send -u critical -i battery-low -t 99999999 "$3"
- echo $1 > /tmp/battery.tmp
- fi
-}
-
-# If upower command is available
-if command -v upower > /dev/null 2>&1 ; then
-
- # Get battery power indicator (charging/discharging/fully charged) and stop script if there is no value for it (if there is no battery in device)
- __bat_power=$(upower -i /org/freedesktop/UPower/devices/battery_BAT0 | grep state | awk '{print $2}')
- if [[ -n ${__bat_per} ]]; then
- exit
- fi
-
- # Set the battery power indicator icon
- __bat_power_ind=""
- if [[ ${__bat_power} = "charging" ]]; then __bat_power_ind=""
- elif [[ ${__bat_power} = "discharging" ]]; then __bat_power_ind=""
- elif [[ ${__bat_power} = "fully-charged" ]]; then __bat_power_ind=""
- fi
-
- # Get the battery percentage, time until the battery is empty and time until the battery is full
- __bat_per=$(upower -i /org/freedesktop/UPower/devices/battery_BAT0 | grep percentage | awk '{print $2}' | sed "s|%||g")
- __time_empt=$(upower -i /org/freedesktop/UPower/devices/battery_BAT0 | grep "time to empty" | awk '{print $4 $5}' | grep -o '^[0-9.]*[a-z]')
- __time_full=$(upower -i /org/freedesktop/UPower/devices/battery_BAT0 | grep "time to full" | awk '{print $4 $5}' | grep -o '^[0-9.]*[a-z]')
-
- # Print the battery power indicator icon, percentage and time until empty or time until full
- echo -n " ${__bat_power_ind} ${__bat_per}%"
- if [[ ${__bat_power} = "discharging" ]]; then
- echo " ${__time_empt}"
- else
- echo " ${__time_full}"
- fi
-
- # Create the temporary battery file, if it doesn't exist
- if [ ! -f "/tmp/battery.tmp" ]; then
- touch /tmp/battery.tmp
- fi
-
- # Setup for battery notifications
- battery_notify 100 'fully-charged' 'Battery 100%'
- battery_notify 80 'charging' 'Battery 80%'
- battery_notify 20 'discharging' 'Battery 20%'
- battery_notify 15 'discharging' 'Battery 15%'
- battery_notify 10 'discharging' 'Battery 10%'
- battery_notify 5 'discharging' 'Battery 5%'
-fi
diff --git a/scripts/dunst-toggler-applet.sh b/scripts/dunst-toggler-applet.sh
deleted file mode 100755
index e9f253e..0000000
--- a/scripts/dunst-toggler-applet.sh
+++ /dev/null
@@ -1,26 +0,0 @@
-#!/bin/bash
-
-function update {
- while :; do
- curr_status=$(dunstctl is-paused)
-
- if [[ "$curr_status" != "$prev_status" ]]; then
- prev_status=$curr_status
-
- if [[ "$curr_status" == "true" ]]; then
- echo icon:/usr/share/icons/tabler-icon-bell-off.png
- echo tooltip:Notifications OFF
- else
- echo icon:/usr/share/icons/tabler-icon-bell.png
- echo tooltip:Notifications ON
- fi
- fi
-
- sleep 0.2
- done
-}
-
-update | \
-yad --notification \
- --listen \
- --command="dunstctl set-paused toggle"
diff --git a/scripts/system/lock.sh b/scripts/system/lock.sh
deleted file mode 100755
index e226b20..0000000
--- a/scripts/system/lock.sh
+++ /dev/null
@@ -1,118 +0,0 @@
-#!/bin/bash
-
-## Helper functions
-res () {
- pkill $@
- nohup $@ 2>&1 &
- disown
-}
-
-# ++=================================++
-# || Actions before and after unlock ||
-# ++=================================++
-
-before_locking () {
- # Disables dunst, my notification daemon, so I don't see notification on lock screen
- # https://github.com/dunst-project/dunst/issues/697
- # https://wiki.archlinux.org/title/Dunst#Disable_dunst_temporarily
- dunstctl set-paused true
- sleep 0.1 # Could fix notifications sometimes being shown https://github.com/dunst-project/dunst/issues/697#issuecomment-1045122705
-}
-
-before_suspend () {
- # Keep track of time when machine is suspended, as well as how long it has been up for
- uptime >> ~/.i3lock/suspend-history
-}
-
-when_unlocked () {
- dunstctl set-paused false # Enables my notification daemon
-
- # Resets programs, in case resolution changes
- res ~/.fehbg # wallpaper
- res lead # hot corners, this is MageJohn's fork: https://github.com/MageJohn/lead
-}
-
-when_unlocked_after_suspend () {
- gtk-launch picom # sometimes my compositor stops working after suspend, this makes sure it's running
-}
-
-# ++==================================++
-# || Prevent locking because of audio ||
-# ++==================================++
-
-# This makes sure to not lock the screen if audio is playing and there are no arguments given
-# It's mainly for preventing automatic screen locking while a video/music is playing
-# If you still want to lock, just give it some argument, doesn't matter what
-if [ $(grep -r 'RUNNING' /proc/asound | wc -l) -gt 0 ] && [ $# -eq 0 ]; then
- exit
-fi
-
-# Show an error message if user is trying to suspend, while audio is playing, because that can mess up sound servers
-# It tries to send a message via zenity, xmessage or notify-send, depending on which is installed
-# but it always sends a text message to stdout. In the end, script execution is stopped.
-if [ $(grep -r 'RUNNING' /proc/asound | wc -l) -gt 1 ] && [[ "$1" == 'suspend' ]]; then
- message='Please, stop all playing audio before trying to suspend!'
-
- if [ -x "$(command -v zenity)" ]; then
- zenity --error --no-wrap --text="$message"
- elif [ -x "$(command -v xmessage)" ]; then
- xmessage -center "$message"
- elif [ -x "$(command -v notify-send)" ]; then
- notify-send -u critical "$message"
- fi
- echo $message
-
- exit
-fi
-
-# ++============================++
-# || Lock if not locked already ||
-# ++============================++
-
-if ! pgrep i3lock 1>&2; then
- # The first line of i3lock arguments uses standard arguments, while the rest of the lines are i3lock-color ones
- # If you want to use i3lock, remove those lines (and the \ at the end)
- # But I highly advise you to use i3lock-color, it's amazing: https://github.com/Raymo111/i3lock-color
- (
- before_locking && \
- i3lock -f -c d49408 -i /home/kamen/.i3lock/lockscreen.png -n \
- -F -k --indicator --keylayout 1 --radius 95 --pass-volume-keys \
- --date-str='%d.%m.%Y' --verif-text='Verifying…' --wrong-text='Wrong!' --noinput-text='No Input!' \
- --insidever-color d47408cc --ringver-color d47408 --insidewrong-color c35b5bcc --ringwrong-color c35b5b \
- --layout-color ffeede --time-color ffeede --date-color ffeede --greeter-color ffeede --verif-color ffeede --wrong-color ffeede \
- ; when_unlocked && if [ -f '/tmp/slept' ]; then when_unlocked_after_suspend; rm /tmp/slept; fi
- ) &
-fi
-
-# ++=========++
-# || Suspend ||
-# ++=========++
-
-if [[ "$1" == 'suspend' ]]; then
- before_suspend
-
- # A file is created to indicate that the system was suspended
- # After i3lock is done (unlocked), existence of this file is checked to determine if
- # script should run when_unlocked_after_suspend function
- touch /tmp/slept
-
- # Wait for the lock screen to appear, before suspending
- # Without this, sometimes you could awaken the computer and see the desktop for a second, before the lock screen loads.
- # During that time, your input is processed by the desktop, giving you control of it, which is a big no-no (even if it's for a second)
- while [ $(xdotool search --onlyvisible --classname i3lock | wc -l) -eq 0 ]; do
- sleep 0.2
- done
-
- # Usually suspending should be done with "systemctl suspend", but I've had issues with that so I directly tell the kernel to sleep the system
- # For that I have a script in /usr/loca/sbin that just contains:
- #
- # #!/bin/bash
- # echo -n mem>/sys/power/state
- #
- # And I've added the following to /etc/sudoers (where kamen is my username), so I don't need to put in my password:
- #
- # kamen ALL = (root) NOPASSWD: /usr/local/sbin/sleep.sh
- # sudo -u root /usr/local/sbin/sleep.sh
- # systemctl suspend
- loginctl suspend
-fi
diff --git a/scripts/system/on-wm-logout.sh b/scripts/system/on-wm-logout.sh
deleted file mode 100755
index 90ebab2..0000000
--- a/scripts/system/on-wm-logout.sh
+++ /dev/null
@@ -1,8 +0,0 @@
-#!/bin/bash
-
-# Gracefully close certain programs
-grace=(brave)
-
-for $app in $grace; do
- timeout 5 pkill -TERM $app
-done
diff --git a/scripts/system/on-wm-session.sh b/scripts/system/on-wm-session.sh
deleted file mode 100755
index e35f4a5..0000000
--- a/scripts/system/on-wm-session.sh
+++ /dev/null
@@ -1,43 +0,0 @@
-#!/bin/bash
-
-device="laptop"
-
-# xhost +si:localuser:root # fixes unable to open display errors: https://askubuntu.com/a/1130413
-~/.fehbg & # wallpaper
-# lead & # hot corners, this is MageJohn's fork: https://github.com/MageJohn/lead
-xcape -e 'Super_L=Super_L|P' & # used for the "windows" menu
-sleep 1 && /usr/libexec/polkit-gnome-authentication-agent-1 &
-
-dunst & # notification daemon
-lxpolkit & # polkit
-xautolock -detectsleep -secure -time 15 -locker ~/scripts/system/lock.sh & # auto lock screen
-tint2 & # taskbar
-picom & # compositor
-setxkbmap -layout "us,bg" -variant ",phonetic" -option "grp:alt_shift_toggle" & # keyboard switching
-
-if [[ $device == "desktop" ]]; then
- xset m 1 1 # disable mouse acceleration (not a very proper way to do it, I know)
-fi
-
-if [[ $device == "laptop" ]]; then
- while :; do if grep -Fq "closed" /proc/acpi/button/lid/LID0/state; then ~/scripts/system/lock.sh suspend && sleep 3; fi; sleep 0.5; done & # lock screen on lid closing; you'll also need to uncomment the HandleLidSwitch variable and assign to it "lock" (HandleLidSwitch=lock) inside /etc/systemd/logind.conf
- libinput-gestures-setup start & # start gestures
- blueberry & # bluetooth app
-fi
-
-pnmixer & # volume applet
-nm-applet & # network applet
-~/scripts/dunst-toggler-applet.sh & # notification toggler
-devilspie2 & # updates windows icons to the ones form the current theme
-
-flameshot & # screenshot utility
-redshift-gtk & # screen color temperature changer
-copyq & # clipboard manager
-barrier & # share mouse and keyboard between devices
-nextcloud & # cloud/source control
-
-electron-mail &
-rambox &
-gtk-launch discord &
-brave-bin &
-claws-mail &
diff --git a/scripts/terminal.sh b/scripts/terminal.sh
deleted file mode 100755
index 2fb7853..0000000
--- a/scripts/terminal.sh
+++ /dev/null
@@ -1,5 +0,0 @@
-#!/bin/bash
-terminator --new-tab --working-directory="$(pwd)"
-
-# To set it as default on cinnamon:
-# gsettings set org.cinnamon.desktop.default-applications.terminal exec /home/kamen/Commonwealth/terminal.sh
diff --git a/scripts/toggle-desktop.sh b/scripts/toggle-desktop.sh
deleted file mode 100755
index b5906bc..0000000
--- a/scripts/toggle-desktop.sh
+++ /dev/null
@@ -1,7 +0,0 @@
-#!/bin/bash
-
-if xprop -root _NET_SHOWING_DESKTOP | egrep '= 1' > /dev/null; then
- wmctrl -k off
-else
- wmctrl -k on
-fi
diff --git a/scripts/toggle-repo.sh b/scripts/toggle-repo.sh
deleted file mode 100755
index ffbcb57..0000000
--- a/scripts/toggle-repo.sh
+++ /dev/null
@@ -1,7 +0,0 @@
-#!/bin/bash
-
-if [[ -d ".git" ]]; then
- sudo mv .git .git.disabled
-else
- sudo mv .git.disabled .git
-fi