From 0af0672f3e25692a3786df8be59dd6faef9e0ee7 Mon Sep 17 00:00:00 2001 From: Jakub Fojt Date: Sun, 12 Sep 2021 09:02:51 +0200 Subject: [PATCH] Move .i3 and diskhealth into modules --- .gitmodules | 12 +- .i3 | 1 + .i3/.autostart | 13 - .i3/base.config | 158 ----- .i3/home.config | 114 ---- .i3/i3exit.sh | 46 -- .i3/lemonbar | 1 - .i3/lock.png | Bin 13359 -> 0 bytes .i3/scripts/adjbr.sh | 32 - .i3/scripts/dpmsctl.sh | 9 - .i3/scripts/lang.sh | 34 -- .i3/scripts/level.sh | 33 -- .i3/scripts/vol.sh | 9 - .i3/workspace_6.json | 127 ---- .i3initrc | 2 +- Pictures/Wallpapers | 1 - scripts/.directory | 6 + scripts/displays.sh | 43 -- scripts/health/du.c | 1140 ------------------------------------ scripts/health/health.c | 220 ------- scripts/health/health.h | 43 -- scripts/health/makefile | 24 - scripts/health/utils.c | 87 --- scripts/health/utils.h | 25 - scripts/healthy-disk-usage | 1 + scripts/set_bg.sh | 24 - 26 files changed, 15 insertions(+), 2190 deletions(-) create mode 160000 .i3 delete mode 100644 .i3/.autostart delete mode 100644 .i3/base.config delete mode 100644 .i3/home.config delete mode 100644 .i3/i3exit.sh delete mode 160000 .i3/lemonbar delete mode 100644 .i3/lock.png delete mode 100755 .i3/scripts/adjbr.sh delete mode 100755 .i3/scripts/dpmsctl.sh delete mode 100755 .i3/scripts/lang.sh delete mode 100755 .i3/scripts/level.sh delete mode 100755 .i3/scripts/vol.sh delete mode 100644 .i3/workspace_6.json delete mode 160000 Pictures/Wallpapers create mode 100755 scripts/.directory delete mode 100755 scripts/displays.sh delete mode 100644 scripts/health/du.c delete mode 100644 scripts/health/health.c delete mode 100644 scripts/health/health.h delete mode 100755 scripts/health/makefile delete mode 100644 scripts/health/utils.c delete mode 100644 scripts/health/utils.h create mode 160000 scripts/healthy-disk-usage delete mode 100755 scripts/set_bg.sh diff --git a/.gitmodules b/.gitmodules index f115854..7f2d43b 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,6 +1,6 @@ -[submodule ".i3/lemonbar"] - path = .i3/lemonbar - url = https://isabeljake.duckdns.org/gitea/kuba/lemonbar.git -[submodule "Pictures/Wallpapers"] - path = Pictures/Wallpapers - url = https://isabeljake.duckdns.org/gitea/kuba/wallpapers.git +[submodule "scripts/healthy-disk-usage"] + path = scripts/healthy-disk-usage + url = https://isabeljake.duckdns.org/gitea/kuba/healthy-disk-usage.git +[submodule ".i3"] + path = .i3 + url = https://isabeljake.duckdns.org/gitea/kuba/i3-config.git diff --git a/.i3 b/.i3 new file mode 160000 index 0000000..6186267 --- /dev/null +++ b/.i3 @@ -0,0 +1 @@ +Subproject commit 61862671baf7ade1a465d046b1739ea317612c15 diff --git a/.i3/.autostart b/.i3/.autostart deleted file mode 100644 index 01c2096..0000000 --- a/.i3/.autostart +++ /dev/null @@ -1,13 +0,0 @@ -sleep 2 -nextcloud & -volnoti & -conky -c ~/.conky/arch/.conkyrc-arch & -conky -c ~/.conky/gmail/.conkyrc-gmail & -conky -c ~/.conky/weather/.conkyrc-weather1 & -conky -c ~/.conky/weather/.conkyrc-weather2 & -conky -c ~/.conky/music/.conkyrc-music & -python ~/.conky/music/playerctl_listen.py & -sh ~/.conky/music/launcher.sh & -source ~/.python-venv.kuba/bin/activate -python ~/.i3/lemonbar/i3_lemonbar_launcher.py --debug >> /tmp/kuba_lemonbar_launcher.log & -compton -b # --config=/home/kuba/.compton.conf diff --git a/.i3/base.config b/.i3/base.config deleted file mode 100644 index 66ceb7f..0000000 --- a/.i3/base.config +++ /dev/null @@ -1,158 +0,0 @@ -# General setup -#### - -set $mod Mod4 -set $TERMINAL terminator --profile=nord - -font pango:FontAwesome 11 - -# Use Mouse+$mod to drag floating windows to their wanted position -floating_modifier $mod - -focus_follows_mouse no -mouse_warping none -workspace_auto_back_and_forth yes -#force_display_urgency_hint 500 ms - -# -# -# Key bindings -#### - -# start a terminal -bindsym $mod+Return exec $TERMINAL - -# kill focused window -bindsym $mod+Shift+q kill - -# start dmenu (a program launcher) -bindsym $mod+d exec dmenu_run -bindsym $mod+Shift+d exec --no-startup-id i3-dmenu-desktop - -# change focus -bindsym $mod+h focus left -bindsym $mod+j focus down -bindsym $mod+k focus up -bindsym $mod+l focus right - -# alternatively, you can use the cursor keys: -bindsym $mod+Left focus left -bindsym $mod+Down focus down -bindsym $mod+Up focus up -bindsym $mod+Right focus right - -# move focused window -bindsym $mod+Shift+h move left -bindsym $mod+Shift+j move down -bindsym $mod+Shift+k move up -bindsym $mod+Shift+l move right - -# alternatively, you can use the cursor keys: -bindsym $mod+Shift+Left move left -bindsym $mod+Shift+Down move down -bindsym $mod+Shift+Up move up -bindsym $mod+Shift+Right move right - -# split in horizontal orientation -bindsym $mod+g split h - -# split in vertical orientation -bindsym $mod+v split v - -# enter fullscreen mode for the focused container -bindsym $mod+f fullscreen toggle - -# change container layout (stacked, tabbed, toggle split) -bindsym $mod+s layout stacking -bindsym $mod+w layout tabbed -bindsym $mod+e layout toggle split - -# toggle tiling / floating -bindsym $mod+Shift+space floating toggle - -# change focus between tiling / floating windows -bindsym $mod+Shift+Return focus mode_toggle - -# focus the parent container -bindsym $mod+a focus parent - -# focus the child container -#bindsym $mod+d focus child - -# switch to workspace -bindsym $mod+1 workspace number $w1 -bindsym $mod+2 workspace number $w2 -bindsym $mod+3 workspace number $w3 -bindsym $mod+4 workspace number $w4 -bindsym $mod+5 workspace number $w5 -bindsym $mod+6 workspace number $w6 -bindsym $mod+7 workspace number $w7 -bindsym $mod+8 workspace number $w8 -bindsym $mod+9 workspace number $w9 -bindsym $mod+0 workspace number $w10 - -# move focused container to workspace -bindsym $mod+Shift+1 move container to workspace number $w1 -bindsym $mod+Shift+2 move container to workspace number $w2 -bindsym $mod+Shift+3 move container to workspace number $w3 -bindsym $mod+Shift+4 move container to workspace number $w4 -bindsym $mod+Shift+5 move container to workspace number $w5 -bindsym $mod+Shift+6 move container to workspace number $w6 -bindsym $mod+Shift+7 move container to workspace number $w7 -bindsym $mod+Shift+8 move container to workspace number $w8 -bindsym $mod+Shift+9 move container to workspace number $w9 -bindsym $mod+Shift+0 move container to workspace number $w10 - -bindsym $mod+o move workspace to output right - -# reload the configuration file -bindsym $mod+Shift+c reload -# restart i3 inplace (preserves your layout/session, can be used to upgrade i3) -bindsym $mod+Shift+r restart -# exit i3 (logs you out of your X session) -bindsym $mod+Shift+e exec "i3-nagbar -t warning -m 'You pressed the exit shortcut. Do you really want to exit i3? This will end your X session.' -b 'Yes, exit i3' 'i3-msg exit'" - -# -# -# Define modes -#### - -set $mode_system System (l) lock, (e) logout, (s) suspend, (h) hibernate, (r) reboot, (Shift+s) shutdown -mode "$mode_system" { - bindsym l exec --no-startup-id .i3/i3exit.sh lock, mode "default" - bindsym e exec --no-startup-id .i3/i3exit.sh logout, mode "default" - bindsym s exec --no-startup-id .i3/i3exit.sh suspend, mode "default" - bindsym h exec --no-startup-id .i3/i3exit.sh hibernate, mode "default" - bindsym r exec --no-startup-id .i3/i3exit.sh reboot, mode "default" - bindsym Shift+s exec --no-startup-id .i3/i3exit.sh shutdown, mode "default" - - # back to normal: Enter or Escape - bindsym Return mode "default"; exec sh .i3/lemonbar/set_mode.sh mode normal - bindsym Escape mode "default"; exec sh .i3/lemonbar/set_mode.sh mode normal -} - -# resize window (you can also use the mouse for that) -mode "resize" { - # These bindings trigger as soon as you enter the resize mode - - # Pressing left will shrink the window’s width. - # Pressing right will grow the window’s width. - # Pressing up will shrink the window’s height. - # Pressing down will grow the window’s height. - bindsym h resize shrink width 10 px or 10 ppt - bindsym k resize grow height 10 px or 10 ppt - bindsym j resize shrink height 10 px or 10 ppt - bindsym l resize grow width 10 px or 10 ppt - - # same bindings, but for the arrow keys - bindsym Left resize shrink width 10 px or 10 ppt - bindsym Up resize grow height 10 px or 10 ppt - bindsym Down resize shrink height 10 px or 10 ppt - bindsym Right resize grow width 10 px or 10 ppt - - # back to normal: Enter or Escape - bindsym Return mode "default" - bindsym Escape mode "default" -} - -bindsym $mod+r mode "resize" diff --git a/.i3/home.config b/.i3/home.config deleted file mode 100644 index dc95174..0000000 --- a/.i3/home.config +++ /dev/null @@ -1,114 +0,0 @@ -set $w1 1 main -set $w2 2 web -set $w3 3 mu -set $w4 4 work -set $w5 5 terms -set $w6 6 stats -set $w7 7 -set $w8 8 -set $w9 9 -set $w10 10 games - -set $below_barY 24 -#set $volX 1400 -#set $brX 1485 -#set $calX 1650 -set $htopX 400 -set $pavuX 800 - -for_window [class="Terminator"] border pixel 0 -for_window [class="YADWIN"] floating enable -for_window [class="FLOAT_PAVU"] floating enable -for_window [class="FLOAT_PAVU"] resize set 800 540 -for_window [class="FLOAT_PAVU"] border pixel 3 -for_window [class="FLOAT_PAVU"] move absolute position $pavuX px $below_barY px -for_window [class="FLOAT_TERM"] floating enable -for_window [class="FLOAT_TERM"] move absolute position $htopX px $below_barY px -for_window [class="FLOAT_TERM"] border pixel 3 -for_window [title="Memory"] floating enable -for_window [class="Matplotlib"] floating enable -for_window [class="Chromium"] border pixel 0 -for_window [class="^.*"] border pixel 0 -for_window [window_type="toolbar"] border pixel 3 -for_window [window_type="splash"] border pixel 3 -for_window [window_type="dialog"] border pixel 3 -for_window [window_type="utility"] border pixel 3 -for_window [window_role="pop-up"] floating enable -for_window [title="VMD 1.9.3 OpenGL Display"] floating enable -for_window [title="Terminator Preferences"] floating enable -for_window [title="Figure *"] floating enable -#for_window [title="VMD"] floating enable - -assign [class="firefox"] → $w2 -assign [class="Chromium"] → $w2 -assign [class="libreoffice*"] → $w4 -assign [class="soffice*"] → $w4 -assign [class="MATLAB*"] → $w4 -assign [window_role="ranger"] → $w1 -assign [window_role="terms"] → $w5 -assign [window_role="stats"] → $w6 -assign [class="Minecraft*"] → $w10 -assign [title="Feed The Beast Launcher*"] → $w10 -#Spotify bug, assign doesn't work -for_window [class="Spotify"] move to workspace $w3 - -# Gaps settings -#### - -gaps inner 0 -gaps outer 0 - -workspace 1 gaps inner 10 -workspace 4 gaps inner 10 -workspace 5 gaps inner 10 -workspace 6 gaps inner 60 - -# Multimedia Bindings -#### - -# pulse audio volume control -bindsym XF86AudioRaiseVolume exec ~/.i3/scripts/level.sh -v up -bindsym XF86AudioLowerVolume exec ~/.i3/scripts/level.sh -v down -bindsym XF86AudioMute exec ~/.i3/scripts/level.sh -v toggle -bindsym XF86MonBrightnessUp exec ~/.i3/scripts/level.sh -b up -bindsym XF86MonBrightnessDown exec ~/.i3/scripts/level.sh -b down -bindsym $mod+F8 exec playerctl play-pause -bindsym $mod+F9 exec playerctl next -bindsym $mod+F7 exec playerctl previous -bindsym XF86AudioPlay exec playerctl play -bindsym XF86AudioPause exec playerctl pause -bindsym XF86AudioNext exec playerctl next -bindsym XF86AudioPrevious exec playerctl previous - -bindsym Print exec scrot '%Y-%m-%d-%T_$wx$h_scrot.png' -e 'mv $f ~/Pictures/screenshots/' -bindsym Shift + Print exec scrot -s '%Y-%m-%d-%T_$wx$h_scrot.png' -e 'mv $f ~/Pictures/screenshots/' - -bindsym $mod+space exec sh ~/.i3/scripts/lang.sh next - -# Exiting -#### - -bindsym XF86Sleep exec sh ~/.i3/i3exit.sh lock -bindsym XF86PowerOff mode "$mode_system"; exec sh .i3/lemonbar/set_mode.sh mode power - - - -#### -# layout settings -#### -bindsym $mod+u exec feh --bg-scale /home/kuba/Pictures/Wallpapers/AxEcN\ -\ Imgur.jpg -#exec compton -b -#workspace 1 main -exec --no-startup-id $TERMINAL --role "ranger" -x ranger - -#exec --no-startup-id i3-msg 'workspace 5 terms" -exec --no-startup-id $TERMINAL --role "terms" -exec --no-startup-id $TERMINAL --role "terms" - -#workspace 6 stats; -exec --no-startup-id i3-msg 'append_layout /home/kuba/.i3/workspace_6.json; rename workspace to "6 stats"' -#Set appropriate background image before starting conkys -exec --no-startup-id feh --bg-scale /home/kuba/Pictures/Wallpapers/6_stats - -#Start conky's in .i3/.autostart -exec sh ~/.i3/.autostart diff --git a/.i3/i3exit.sh b/.i3/i3exit.sh deleted file mode 100644 index 31ce143..0000000 --- a/.i3/i3exit.sh +++ /dev/null @@ -1,46 +0,0 @@ -#!/bin/sh - -lock() { - # Credit: https://github.com/petvas/i3lock-blur - # TODO Handle several screens - TMPBG=/tmp/screen_locked.png - LOCK=~/.i3/lock.png - RES=$(xrandr | grep 'current' | sed -E 's/.*current\s([0-9]+)\sx\s([0-9]+).*/\1x\2/') - - #ffmpeg -f x11grab -video_size $RES -y -i $DISPLAY -i $LOCK -filter_complex \ - # "boxblur=5:1,overlay=(main_w-overlay_w)/2:(main_h-overlay_h)/2" \ - # -vframes 1 $TMPBG -loglevel quiet - ffmpeg -f x11grab -video_size $RES -y -i $DISPLAY -filter_complex \ - "boxblur=5:1" -vframes 1 $TMPBG -loglevel quiet - i3lock -i $TMPBG - rm $TMPBG -} - -case "$1" in - lock) - lock - ;; - logout) - i3-msg exit - ;; - suspend) - lock && sudo pm-suspend - ;; - lidclose) - lock && sudo pm-suspend - ;; - hibernate) - lock && sudo pm-hibernate - ;; - reboot) - systemctl reboot - ;; - shutdown) - systemctl poweroff - ;; - *) - echo "Usage: $0 {lock|logout|suspend|hibernate|reboot|shutdown}" - exit 2 -esac - -exit 0 diff --git a/.i3/lemonbar b/.i3/lemonbar deleted file mode 160000 index c03598c..0000000 --- a/.i3/lemonbar +++ /dev/null @@ -1 +0,0 @@ -Subproject commit c03598c5b2f77b68243059e6247dfc7b8b00558c diff --git a/.i3/lock.png b/.i3/lock.png deleted file mode 100644 index 283f14c435e31fdfce0324fb73f69a3726c1f3c7..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 13359 zcmch;c|4R~_&A(ADNP$9BQhOw8%l5OUrqGUUn!?Az~5eV^y~{_*_zyq;dKhB^0Hu5<3|T<3k>*V~p3HPE@Y3EJcT-pYXwEymophsYk2E(Pi!9Tf+~WHNQ`pI7JvEozi^LPK(Q~d zLl%F{y=K-FA9zY|Q-dx<;V#QN9dl}3m@}F>_^ZEXkK{woHzoU*ME#ssD;4lPJ2;7Z zo6#q25~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B0*aXV*LZQ2q6}>*NI1z z=Q33m^^4V<-jnRx* z-(y-MPiaJ-Jg^;{^3`BHs|TA}y<=V|_X)e-U0s~|J_-a{E|!PMEnZLt?QV1dnWXYH zE=#;O0JSkNKOR%jw&Qo#Wb6F;YA(n@kDN_>40Z)0Az)>sncCdnN?M$qi;K`R@AUQ2 xsrcI1`iy3qBx=PF;-$ICON'" - "--value" "$LEVEL" "--no-buttons" - "--geometry=15x150" "--vertical" "--text-align" "center" "$TIMER" "--print-partial") -YARGS=${YADARGS[@]} - -FIFO="$2" - -(echo "kill_unfocus $BASHPID" > $FIFO; exec sh -c "yad $YARGS") | \ -while read out; do - ~/.i3/scripts/level.sh -b set $out -done diff --git a/.i3/scripts/dpmsctl.sh b/.i3/scripts/dpmsctl.sh deleted file mode 100755 index d40c707..0000000 --- a/.i3/scripts/dpmsctl.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/sh -STATUS=`xset q | awk '{for (I=1;I<=NF;I++) if ($I == "DPMS" && $(I+1) == "is") {print $(I+2)};}'` -if [ "$STATUS" == "Enabled" ]; then - xset -dpms - yad --timeout 1 --text "DPMS Disabled" --no-buttons --sticky --on-top -else - xset dpms - yad --timeout 1 --text "DPMS Enabled" --no-buttons --sticky --on-top -fi diff --git a/.i3/scripts/lang.sh b/.i3/scripts/lang.sh deleted file mode 100755 index 5e87a3e..0000000 --- a/.i3/scripts/lang.sh +++ /dev/null @@ -1,34 +0,0 @@ -#!/bin/bash -panel_fifo="/tmp/i3_lemonbar1_${USER}" -panel_commands="/tmp/i3_lemonbar2_${USER}" - -function show(){ - setxkbmap -print | grep xkb_symbols | awk '{print $4}' | awk -F"+" '{print $2}' -} -if [ $# -lt 1 ]; then - echo LANG$(show) -fi -if [ "$1" == "next" ]; then - cur=$(show) - next='se' - if [ "$cur" == "se" ]; then - next='pl' - fi - setxkbmap $next - if [ -e $panel_fifo ]; then - echo -e "LANG$next" > "${panel_fifo}" - fi - if [ -e $panel_commands ]; then - echo -e "setlang $next" > "${panel_commands}" - fi -elif [ "$1" == "qset" ]; then - next=$2 - setxkbmap $next - if [ -e $panel_fifo ]; then - echo -e "LANG$next" > "${panel_fifo}" - fi -elif [ "$1" == "show" ]; then - show -else - exit 1 -fi diff --git a/.i3/scripts/level.sh b/.i3/scripts/level.sh deleted file mode 100755 index 8545745..0000000 --- a/.i3/scripts/level.sh +++ /dev/null @@ -1,33 +0,0 @@ -#!/bin/bash -panel_fifo="/tmp/i3_lemonbar1_${USER}" -panel_commands="/tmp/i3_lemonbar2_${USER}" - -if [[ "$1" == "-b" ]]; then - icon="-s /usr/share/pixmaps/volnoti/display-brightness-symbolic.svg" - if [[ "$2" == "up" ]]; then - level=$(brillo -A 5 -u 100000; brillo) - elif [[ "$2" == "down" ]]; then - level=$(brillo -U 5 -u 100000; brillo) - elif [[ "$2" == "set" ]]; then - level=$(brillo -S $3; brillo) - fi - echo "BRIGHT$level" > $panel_fifo -elif [[ "$1" == "-v" ]]; then - if [[ "$2" == "up" ]]; then - amixer -q set Master 5%+ - elif [[ "$2" == "down" ]]; then - amixer -q set Master 5%- - elif [[ "$2" == "toggle" ]]; then - amixer -q set Master toggle - fi - level=$(~/.i3/lemonbar/get_vol.sh) - if [[ "$level" == "MUTE" ]]; then - level="-m" - elif [[ "$level" == "NONE" ]]; then - echo "Missing" - fi -fi - -if [[ "$2" != "set" ]]; then - volnoti-show $icon $level -fi diff --git a/.i3/scripts/vol.sh b/.i3/scripts/vol.sh deleted file mode 100755 index 179ffc9..0000000 --- a/.i3/scripts/vol.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/bash - -[[ "$1" == "up" ]] && amixer set Master 5%+ -[[ "$1" == "down" ]] && amixer set Master 5%- -[[ "$1" == "mute" ]] && amixer sset Master toggle - -VOL=$(amixer get Master | grep 'Front Left:' | cut -c 31-33) -[[ $(amixer get Master | grep "\[off\]") ]] && sudo -u kuba volnoti-show -m $VOL && exit -sudo -u kuba volnoti-show $VOL diff --git a/.i3/workspace_6.json b/.i3/workspace_6.json deleted file mode 100644 index 5aec8a8..0000000 --- a/.i3/workspace_6.json +++ /dev/null @@ -1,127 +0,0 @@ -{ -"layout": "splith", -"nodes": [ -{ - "border": "normal", - "floating": "auto_off", - "layout": "splitv", - "percent": 0.65, - "type": "con", - "nodes": [ - { - "border": "normal", - "floating": "auto_off", - "layout": "splith", - "percent": 0.5, - "type": "con", - "nodes": [ - { - "border": "none", - "current_border_width": 2, - "floating": "auto_off", - "geometry": { - "height": 10, - "width": 10, - "x": 0, - "y": 0 - }, - "name": "Conky (kuba-Arch)", - "percent": 1, - "swallows": [ - { - "class": "Conky-arch" - } - ], - "type": "con" - } - ] - }, - { - "border": "none", - "current_border_width": 2, - "floating": "auto_off", - "geometry": { - "height": 434, - "width": 722, - "x": 0, - "y": 0 - }, - "name": "Conky (kuba-Arch)", - "percent": 0.5, - "swallows": [ - { - "class": "Conky-gmail" - } - ], - "type": "con" - } - ] -}, -{ - "border": "normal", - "floating": "auto_off", - "layout": "splitv", - "percent": 0.35, - "type": "con", - "nodes": [ - { - "border": "none", - "current_border_width": 2, - "floating": "auto_off", - "geometry": { - "height": 32, - "width": 32, - "x": 0, - "y": 0 - }, - "name": "Conky (kuba-Arch)", - "percent": 0.20, - "swallows": [ - { - "class": "Conky-weather" - } - ], - "type": "con" - }, - { - "border": "none", - "current_border_width": 2, - "floating": "auto_off", - "geometry": { - "height": 32, - "width": 32, - "x": 0, - "y": 0 - }, - "name": "Conky (kuba-Arch)", - "percent": 0.20, - "swallows": [ - { - "class": "Conky-weather" - } - ], - "type": "con" - }, - { - "border": "none", - "current_border_width": 2, - "floating": "auto_off", - "geometry": { - "height": 10, - "width": 10, - "x": 0, - "y": 0 - }, - "name": "Conky (kuba-Arch)", - "percent": 0.60, - "swallows": [ - { - "class": "Conky-music" - } - ], - "type": "con" - } - ] -} -] -} diff --git a/.i3initrc b/.i3initrc index 58452bb..393a37a 100644 --- a/.i3initrc +++ b/.i3initrc @@ -18,5 +18,5 @@ elif [ "`hostname`" = "JakubArch" ] && [ -f ~/.i3/work.config ]; then fi #exec i3 -c $i3config -V >> ~/${WM}.log 2>&1 -sh ~/scripts/displays.sh auto +sh ~/.i3/scripts/displays.sh auto exec i3 -c $i3config diff --git a/Pictures/Wallpapers b/Pictures/Wallpapers deleted file mode 160000 index 6eb63d5..0000000 --- a/Pictures/Wallpapers +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 6eb63d5a8d4f9d348a7928a62b702b84b93dba07 diff --git a/scripts/.directory b/scripts/.directory new file mode 100755 index 0000000..116e242 --- /dev/null +++ b/scripts/.directory @@ -0,0 +1,6 @@ +[Dolphin] +Timestamp=2014,5,7,20,54,5 +Version=3 + +[Settings] +HiddenFilesShown=true diff --git a/scripts/displays.sh b/scripts/displays.sh deleted file mode 100755 index 4050141..0000000 --- a/scripts/displays.sh +++ /dev/null @@ -1,43 +0,0 @@ -#!/bin/bash - -function primary() { - xrandr | grep primary | awk '{print $1}' -} - -displays=$(xrandr --listactivemonitors | grep -v Monitors | awk '{print $NF}') -case "$1" in - "auto") - echo "$displays" | while read display; do - xrandr --output $display --auto - done - ;; - "connected") - echo "$displays" - ;; - "lemonbar") - echo "DISP ${displays[@]}" | sed "s/ /:/g" - ;; - *) - # -F Fix strings, -x exactly, -q quiet - if echo "$displays" | grep -Fqx "$1"; then - case "$2" in - "off") - action="--off" - ;; - "mirror") - action="--same-as $(primary)" - ;; - "left") - action="--left-of $(primary) --auto" - ;; - "right") - action="--right-of $(primary) --auto" - ;; - *) - exit 1 - ;; - esac - xrandr --output $1 $action - fi -esac - diff --git a/scripts/health/du.c b/scripts/health/du.c deleted file mode 100644 index 4b7192c..0000000 --- a/scripts/health/du.c +++ /dev/null @@ -1,1140 +0,0 @@ -/* du -- summarize disk usage - Copyright (C) 1988-2019 Free Software Foundation, Inc. - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . */ - -/* Differences from the Unix du: - * Doesn't simply ignore the names of regular files given as arguments - when -a is given. - - By tege@sics.se, Torbjorn Granlund, - and djm@ai.mit.edu, David MacKenzie. - Variable blocks added by lm@sgi.com and eggert@twinsun.com. - Rewritten to use nftw, then to use fts by Jim Meyering. */ - -#include -#include -#include -#include -#include "system.h" -#include "argmatch.h" -#include "argv-iter.h" -#include "di-set.h" -#include "die.h" -#include "error.h" -#include "exclude.h" -#include "fprintftime.h" -#include "human.h" -#include "mountlist.h" -#include "quote.h" -#include "stat-size.h" -#include "stat-time.h" -#include "stdio--.h" -#include "xfts.h" -#include "xstrtol.h" - -extern bool fts_debug; - -/* The official name of this program (e.g., no 'g' prefix). */ -#define PROGRAM_NAME "du" - -#define AUTHORS \ - proper_name ("Torbjorn Granlund"), \ - proper_name ("David MacKenzie"), \ - proper_name ("Paul Eggert"), \ - proper_name ("Jim Meyering") - -#if DU_DEBUG -# define FTS_CROSS_CHECK(Fts) fts_cross_check (Fts) -#else -# define FTS_CROSS_CHECK(Fts) -#endif - -/* A set of dev/ino pairs to help identify files and directories - whose sizes have already been counted. */ -static struct di_set *di_files; - -/* A set containing a dev/ino pair for each local mount point directory. */ -static struct di_set *di_mnt; - -/* Keep track of the preceding "level" (depth in hierarchy) - from one call of process_file to the next. */ -static size_t prev_level; - -/* Define a class for collecting directory information. */ -struct duinfo -{ - /* Size of files in directory. */ - uintmax_t size; - - /* Number of inodes in directory. */ - uintmax_t inodes; - - /* Latest timestamp found. If tmax.tv_sec == TYPE_MINIMUM (time_t) - && tmax.tv_nsec < 0, no timestamp has been found. */ - struct timespec tmax; -}; - -/* Initialize directory data. */ -static inline void -duinfo_init (struct duinfo *a) -{ - a->size = 0; - a->inodes = 0; - a->tmax.tv_sec = TYPE_MINIMUM (time_t); - a->tmax.tv_nsec = -1; -} - -/* Set directory data. */ -static inline void -duinfo_set (struct duinfo *a, uintmax_t size, struct timespec tmax) -{ - a->size = size; - a->inodes = 1; - a->tmax = tmax; -} - -/* Accumulate directory data. */ -static inline void -duinfo_add (struct duinfo *a, struct duinfo const *b) -{ - uintmax_t sum = a->size + b->size; - a->size = a->size <= sum ? sum : UINTMAX_MAX; - a->inodes = a->inodes + b->inodes; - if (timespec_cmp (a->tmax, b->tmax) < 0) - a->tmax = b->tmax; -} - -/* A structure for per-directory level information. */ -struct dulevel -{ - /* Entries in this directory. */ - struct duinfo ent; - - /* Total for subdirectories. */ - struct duinfo subdir; -}; - -/* If true, display counts for all files, not just directories. */ -static bool opt_all = false; - -/* If true, rather than using the disk usage of each file, - use the apparent size (a la stat.st_size). */ -static bool apparent_size = false; - -/* If true, count each hard link of files with multiple links. */ -static bool opt_count_all = false; - -/* If true, hash all files to look for hard links. */ -static bool hash_all; - -/* If true, output the NUL byte instead of a newline at the end of each line. */ -static bool opt_nul_terminate_output = false; - -/* If true, print a grand total at the end. */ -static bool print_grand_total = false; - -/* If nonzero, do not add sizes of subdirectories. */ -static bool opt_separate_dirs = false; - -/* Show the total for each directory (and file if --all) that is at - most MAX_DEPTH levels down from the root of the hierarchy. The root - is at level 0, so 'du --max-depth=0' is equivalent to 'du -s'. */ -static size_t max_depth = SIZE_MAX; - -/* Only output entries with at least this SIZE if positive, - or at most if negative. See --threshold option. */ -static intmax_t opt_threshold = 0; - -/* Human-readable options for output. */ -static int human_output_opts; - -/* Output inodes count instead of blocks used. */ -static bool opt_inodes = false; - -/* If true, print most recently modified date, using the specified format. */ -static bool opt_time = false; - -/* Type of time to display. controlled by --time. */ - -enum time_type - { - time_mtime, /* default */ - time_ctime, - time_atime - }; - -static enum time_type time_type = time_mtime; - -/* User specified date / time style */ -static char const *time_style = NULL; - -/* Format used to display date / time. Controlled by --time-style */ -static char const *time_format = NULL; - -/* The local time zone rules, as per the TZ environment variable. */ -static timezone_t localtz; - -/* The units to use when printing sizes. */ -static uintmax_t output_block_size; - -/* File name patterns to exclude. */ -static struct exclude *exclude; - -/* Grand total size of all args, in bytes. Also latest modified date. */ -static struct duinfo tot_dui; - -#define IS_DIR_TYPE(Type) \ - ((Type) == FTS_DP \ - || (Type) == FTS_DNR) - -/* For long options that have no equivalent short option, use a - non-character as a pseudo short option, starting with CHAR_MAX + 1. */ -enum -{ - APPARENT_SIZE_OPTION = CHAR_MAX + 1, - EXCLUDE_OPTION, - FILES0_FROM_OPTION, - HUMAN_SI_OPTION, - FTS_DEBUG, - TIME_OPTION, - TIME_STYLE_OPTION, - INODES_OPTION -}; - -static struct option const long_options[] = -{ - {"all", no_argument, NULL, 'a'}, - {"apparent-size", no_argument, NULL, APPARENT_SIZE_OPTION}, - {"block-size", required_argument, NULL, 'B'}, - {"bytes", no_argument, NULL, 'b'}, - {"count-links", no_argument, NULL, 'l'}, - /* {"-debug", no_argument, NULL, FTS_DEBUG}, */ - {"dereference", no_argument, NULL, 'L'}, - {"dereference-args", no_argument, NULL, 'D'}, - {"exclude", required_argument, NULL, EXCLUDE_OPTION}, - {"exclude-from", required_argument, NULL, 'X'}, - {"files0-from", required_argument, NULL, FILES0_FROM_OPTION}, - {"human-readable", no_argument, NULL, 'h'}, - {"inodes", no_argument, NULL, INODES_OPTION}, - {"si", no_argument, NULL, HUMAN_SI_OPTION}, - {"max-depth", required_argument, NULL, 'd'}, - {"null", no_argument, NULL, '0'}, - {"no-dereference", no_argument, NULL, 'P'}, - {"one-file-system", no_argument, NULL, 'x'}, - {"separate-dirs", no_argument, NULL, 'S'}, - {"summarize", no_argument, NULL, 's'}, - {"total", no_argument, NULL, 'c'}, - {"threshold", required_argument, NULL, 't'}, - {"time", optional_argument, NULL, TIME_OPTION}, - {"time-style", required_argument, NULL, TIME_STYLE_OPTION}, - {GETOPT_HELP_OPTION_DECL}, - {GETOPT_VERSION_OPTION_DECL}, - {NULL, 0, NULL, 0} -}; - -static char const *const time_args[] = -{ - "atime", "access", "use", "ctime", "status", NULL -}; -static enum time_type const time_types[] = -{ - time_atime, time_atime, time_atime, time_ctime, time_ctime -}; -ARGMATCH_VERIFY (time_args, time_types); - -/* 'full-iso' uses full ISO-style dates and times. 'long-iso' uses longer - ISO-style timestamps, though shorter than 'full-iso'. 'iso' uses shorter - ISO-style timestamps. */ -enum time_style - { - full_iso_time_style, /* --time-style=full-iso */ - long_iso_time_style, /* --time-style=long-iso */ - iso_time_style /* --time-style=iso */ - }; - -static char const *const time_style_args[] = -{ - "full-iso", "long-iso", "iso", NULL -}; -static enum time_style const time_style_types[] = -{ - full_iso_time_style, long_iso_time_style, iso_time_style -}; -ARGMATCH_VERIFY (time_style_args, time_style_types); - -void -usage (int status) -{ - if (status != EXIT_SUCCESS) - emit_try_help (); - else - { - printf (_("\ -Usage: %s [OPTION]... [FILE]...\n\ - or: %s [OPTION]... --files0-from=F\n\ -"), program_name, program_name); - fputs (_("\ -Summarize disk usage of the set of FILEs, recursively for directories.\n\ -"), stdout); - - emit_mandatory_arg_note (); - - fputs (_("\ - -0, --null end each output line with NUL, not newline\n\ - -a, --all write counts for all files, not just directories\n\ - --apparent-size print apparent sizes, rather than disk usage; although\ -\n\ - the apparent size is usually smaller, it may be\n\ - larger due to holes in ('sparse') files, internal\n\ - fragmentation, indirect blocks, and the like\n\ -"), stdout); - fputs (_("\ - -B, --block-size=SIZE scale sizes by SIZE before printing them; e.g.,\n\ - '-BM' prints sizes in units of 1,048,576 bytes;\n\ - see SIZE format below\n\ - -b, --bytes equivalent to '--apparent-size --block-size=1'\n\ - -c, --total produce a grand total\n\ - -D, --dereference-args dereference only symlinks that are listed on the\n\ - command line\n\ - -d, --max-depth=N print the total for a directory (or file, with --all)\n\ - only if it is N or fewer levels below the command\n\ - line argument; --max-depth=0 is the same as\n\ - --summarize\n\ -"), stdout); - fputs (_("\ - --files0-from=F summarize disk usage of the\n\ - NUL-terminated file names specified in file F;\n\ - if F is -, then read names from standard input\n\ - -H equivalent to --dereference-args (-D)\n\ - -h, --human-readable print sizes in human readable format (e.g., 1K 234M 2G)\ -\n\ - --inodes list inode usage information instead of block usage\n\ -"), stdout); - fputs (_("\ - -k like --block-size=1K\n\ - -L, --dereference dereference all symbolic links\n\ - -l, --count-links count sizes many times if hard linked\n\ - -m like --block-size=1M\n\ -"), stdout); - fputs (_("\ - -P, --no-dereference don't follow any symbolic links (this is the default)\n\ - -S, --separate-dirs for directories do not include size of subdirectories\n\ - --si like -h, but use powers of 1000 not 1024\n\ - -s, --summarize display only a total for each argument\n\ -"), stdout); - fputs (_("\ - -t, --threshold=SIZE exclude entries smaller than SIZE if positive,\n\ - or entries greater than SIZE if negative\n\ - --time show time of the last modification of any file in the\n\ - directory, or any of its subdirectories\n\ - --time=WORD show time as WORD instead of modification time:\n\ - atime, access, use, ctime or status\n\ - --time-style=STYLE show times using STYLE, which can be:\n\ - full-iso, long-iso, iso, or +FORMAT;\n\ - FORMAT is interpreted like in 'date'\n\ -"), stdout); - fputs (_("\ - -X, --exclude-from=FILE exclude files that match any pattern in FILE\n\ - --exclude=PATTERN exclude files that match PATTERN\n\ - -x, --one-file-system skip directories on different file systems\n\ -"), stdout); - fputs (HELP_OPTION_DESCRIPTION, stdout); - fputs (VERSION_OPTION_DESCRIPTION, stdout); - emit_blocksize_note ("DU"); - emit_size_note (); - emit_ancillary_info (PROGRAM_NAME); - } - exit (status); -} - -/* Try to insert the INO/DEV pair into DI_SET. - Return true if the pair is successfully inserted, - false if the pair was already there. */ -static bool -hash_ins (struct di_set *di_set, ino_t ino, dev_t dev) -{ - int inserted = di_set_insert (di_set, dev, ino); - if (inserted < 0) - xalloc_die (); - return inserted; -} - -/* FIXME: this code is nearly identical to code in date.c */ -/* Display the date and time in WHEN according to the format specified - in FORMAT. */ - -static void -show_date (const char *format, struct timespec when, timezone_t tz) -{ - struct tm tm; - if (localtime_rz (tz, &when.tv_sec, &tm)) - fprintftime (stdout, format, &tm, tz, when.tv_nsec); - else - { - char buf[INT_BUFSIZE_BOUND (intmax_t)]; - char *when_str = timetostr (when.tv_sec, buf); - error (0, 0, _("time %s is out of range"), quote (when_str)); - fputs (when_str, stdout); - } -} - -/* Print N_BYTES. Convert it to a readable value before printing. */ - -static void -print_only_size (uintmax_t n_bytes) -{ - char buf[LONGEST_HUMAN_READABLE + 1]; - fputs ((n_bytes == UINTMAX_MAX - ? _("Infinity") - : human_readable (n_bytes, buf, human_output_opts, - 1, output_block_size)), - stdout); -} - -/* Print size (and optionally time) indicated by *PDUI, followed by STRING. */ - -static void -print_size (const struct duinfo *pdui, const char *string) -{ - print_only_size (opt_inodes - ? pdui->inodes - : pdui->size); - - if (opt_time) - { - putchar ('\t'); - show_date (time_format, pdui->tmax, localtz); - } - printf ("\t%s%c", string, opt_nul_terminate_output ? '\0' : '\n'); - fflush (stdout); -} - -/* Fill the di_mnt set with local mount point dev/ino pairs. */ - -static void -fill_mount_table (void) -{ - struct mount_entry *mnt_ent = read_file_system_list (false); - while (mnt_ent) - { - struct mount_entry *mnt_free; - if (!mnt_ent->me_remote && !mnt_ent->me_dummy) - { - struct stat buf; - if (!stat (mnt_ent->me_mountdir, &buf)) - hash_ins (di_mnt, buf.st_ino, buf.st_dev); - else - { - /* Ignore stat failure. False positives are too common. - E.g., "Permission denied" on /run/user//gvfs. */ - } - } - - mnt_free = mnt_ent; - mnt_ent = mnt_ent->me_next; - free_mount_entry (mnt_free); - } -} - -/* This function checks whether any of the directories in the cycle that - fts detected is a mount point. */ - -static bool -mount_point_in_fts_cycle (FTSENT const *ent) -{ - FTSENT const *cycle_ent = ent->fts_cycle; - - if (!di_mnt) - { - /* Initialize the set of dev,inode pairs. */ - di_mnt = di_set_alloc (); - if (!di_mnt) - xalloc_die (); - - fill_mount_table (); - } - - while (ent && ent != cycle_ent) - { - if (di_set_lookup (di_mnt, ent->fts_statp->st_dev, - ent->fts_statp->st_ino) > 0) - { - return true; - } - ent = ent->fts_parent; - } - - return false; -} - -/* This function is called once for every file system object that fts - encounters. fts does a depth-first traversal. This function knows - that and accumulates per-directory totals based on changes in - the depth of the current entry. It returns true on success. */ - -static bool -process_file (FTS *fts, FTSENT *ent) -{ - bool ok = true; - struct duinfo dui; - struct duinfo dui_to_print; - size_t level; - static size_t n_alloc; - /* First element of the structure contains: - The sum of the st_size values of all entries in the single directory - at the corresponding level. Although this does include the st_size - corresponding to each subdirectory, it does not include the size of - any file in a subdirectory. Also corresponding last modified date. - Second element of the structure contains: - The sum of the sizes of all entries in the hierarchy at or below the - directory at the specified level. */ - static struct dulevel *dulvl; - - const char *file = ent->fts_path; - const struct stat *sb = ent->fts_statp; - int info = ent->fts_info; - - if (info == FTS_DNR) - { - /* An error occurred, but the size is known, so count it. */ - error (0, ent->fts_errno, _("cannot read directory %s"), quoteaf (file)); - ok = false; - } - else if (info != FTS_DP) - { - bool excluded = excluded_file_name (exclude, file); - if (! excluded) - { - /* Make the stat buffer *SB valid, or fail noisily. */ - - if (info == FTS_NSOK) - { - fts_set (fts, ent, FTS_AGAIN); - FTSENT const *e = fts_read (fts); - assert (e == ent); - info = ent->fts_info; - } - - if (info == FTS_NS || info == FTS_SLNONE) - { - error (0, ent->fts_errno, _("cannot access %s"), quoteaf (file)); - return false; - } - - /* The --one-file-system (-x) option cannot exclude anything - specified on the command-line. By definition, it can exclude - a file or directory only when its device number is different - from that of its just-processed parent directory, and du does - not process the parent of a command-line argument. */ - if (fts->fts_options & FTS_XDEV - && FTS_ROOTLEVEL < ent->fts_level - && fts->fts_dev != sb->st_dev) - excluded = true; - } - - if (excluded - || (! opt_count_all - && (hash_all || (! S_ISDIR (sb->st_mode) && 1 < sb->st_nlink)) - && ! hash_ins (di_files, sb->st_ino, sb->st_dev))) - { - /* If ignoring a directory in preorder, skip its children. - Ignore the next fts_read output too, as it's a postorder - visit to the same directory. */ - if (info == FTS_D) - { - fts_set (fts, ent, FTS_SKIP); - FTSENT const *e = fts_read (fts); - assert (e == ent); - } - - return true; - } - - switch (info) - { - case FTS_D: - return true; - - case FTS_ERR: - /* An error occurred, but the size is known, so count it. */ - error (0, ent->fts_errno, "%s", quotef (file)); - ok = false; - break; - - case FTS_DC: - /* If not following symlinks and not a (bind) mount point. */ - if (cycle_warning_required (fts, ent) - && ! mount_point_in_fts_cycle (ent)) - { - emit_cycle_warning (file); - return false; - } - return true; - } - } - - duinfo_set (&dui, - (apparent_size - ? MAX (0, sb->st_size) - : (uintmax_t) ST_NBLOCKS (*sb) * ST_NBLOCKSIZE), - (time_type == time_mtime ? get_stat_mtime (sb) - : time_type == time_atime ? get_stat_atime (sb) - : get_stat_ctime (sb))); - - level = ent->fts_level; - dui_to_print = dui; - - if (n_alloc == 0) - { - n_alloc = level + 10; - dulvl = xcalloc (n_alloc, sizeof *dulvl); - } - else - { - if (level == prev_level) - { - /* This is usually the most common case. Do nothing. */ - } - else if (level > prev_level) - { - /* Descending the hierarchy. - Clear the accumulators for *all* levels between prev_level - and the current one. The depth may change dramatically, - e.g., from 1 to 10. */ - - if (n_alloc <= level) - { - dulvl = xnrealloc (dulvl, level, 2 * sizeof *dulvl); - n_alloc = level * 2; - } - - for (size_t i = prev_level + 1; i <= level; i++) - { - duinfo_init (&dulvl[i].ent); - duinfo_init (&dulvl[i].subdir); - } - } - else /* level < prev_level */ - { - /* Ascending the hierarchy. - Process a directory only after all entries in that - directory have been processed. When the depth decreases, - propagate sums from the children (prev_level) to the parent. - Here, the current level is always one smaller than the - previous one. */ - assert (level == prev_level - 1); - duinfo_add (&dui_to_print, &dulvl[prev_level].ent); - if (!opt_separate_dirs) - duinfo_add (&dui_to_print, &dulvl[prev_level].subdir); - duinfo_add (&dulvl[level].subdir, &dulvl[prev_level].ent); - duinfo_add (&dulvl[level].subdir, &dulvl[prev_level].subdir); - } - } - - prev_level = level; - - /* Let the size of a directory entry contribute to the total for the - containing directory, unless --separate-dirs (-S) is specified. */ - if (! (opt_separate_dirs && IS_DIR_TYPE (info))) - duinfo_add (&dulvl[level].ent, &dui); - - /* Even if this directory is unreadable or we can't chdir into it, - do let its size contribute to the total. */ - duinfo_add (&tot_dui, &dui); - - if ((IS_DIR_TYPE (info) && level <= max_depth) - || (opt_all && level <= max_depth) - || level == 0) - { - /* Print or elide this entry according to the --threshold option. */ - uintmax_t v = opt_inodes ? dui_to_print.inodes : dui_to_print.size; - if (opt_threshold < 0 - ? v <= -opt_threshold - : v >= opt_threshold) - print_size (&dui_to_print, file); - } - - return ok; -} - -/* Recursively print the sizes of the directories (and, if selected, files) - named in FILES, the last entry of which is NULL. - BIT_FLAGS controls how fts works. - Return true if successful. */ - -static bool -du_files (char **files, int bit_flags) -{ - bool ok = true; - - if (*files) - { - FTS *fts = xfts_open (files, bit_flags, NULL); - - while (1) - { - FTSENT *ent; - - ent = fts_read (fts); - if (ent == NULL) - { - if (errno != 0) - { - error (0, errno, _("fts_read failed: %s"), - quotef (fts->fts_path)); - ok = false; - } - - /* When exiting this loop early, be careful to reset the - global, prev_level, used in process_file. Otherwise, its - (level == prev_level - 1) assertion could fail. */ - prev_level = 0; - break; - } - FTS_CROSS_CHECK (fts); - - ok &= process_file (fts, ent); - } - - if (fts_close (fts) != 0) - { - error (0, errno, _("fts_close failed")); - ok = false; - } - } - - return ok; -} - -int -main (int argc, char **argv) -{ - char *cwd_only[2]; - bool max_depth_specified = false; - bool ok = true; - char *files_from = NULL; - - /* Bit flags that control how fts works. */ - int bit_flags = FTS_NOSTAT; - - /* Select one of the three FTS_ options that control if/when - to follow a symlink. */ - int symlink_deref_bits = FTS_PHYSICAL; - - /* If true, display only a total for each argument. */ - bool opt_summarize_only = false; - - cwd_only[0] = bad_cast ("."); - cwd_only[1] = NULL; - - initialize_main (&argc, &argv); - set_program_name (argv[0]); - setlocale (LC_ALL, ""); - bindtextdomain (PACKAGE, LOCALEDIR); - textdomain (PACKAGE); - - atexit (close_stdout); - - exclude = new_exclude (); - - human_options (getenv ("DU_BLOCK_SIZE"), - &human_output_opts, &output_block_size); - - while (true) - { - int oi = -1; - int c = getopt_long (argc, argv, "0abd:chHklmst:xB:DLPSX:", - long_options, &oi); - if (c == -1) - break; - - switch (c) - { -#if DU_DEBUG - case FTS_DEBUG: - fts_debug = true; - break; -#endif - - case '0': - opt_nul_terminate_output = true; - break; - - case 'a': - opt_all = true; - break; - - case APPARENT_SIZE_OPTION: - apparent_size = true; - break; - - case 'b': - apparent_size = true; - human_output_opts = 0; - output_block_size = 1; - break; - - case 'c': - print_grand_total = true; - break; - - case 'h': - human_output_opts = human_autoscale | human_SI | human_base_1024; - output_block_size = 1; - break; - - case HUMAN_SI_OPTION: - human_output_opts = human_autoscale | human_SI; - output_block_size = 1; - break; - - case 'k': - human_output_opts = 0; - output_block_size = 1024; - break; - - case 'd': /* --max-depth=N */ - { - unsigned long int tmp_ulong; - if (xstrtoul (optarg, NULL, 0, &tmp_ulong, NULL) == LONGINT_OK - && tmp_ulong <= SIZE_MAX) - { - max_depth_specified = true; - max_depth = tmp_ulong; - } - else - { - error (0, 0, _("invalid maximum depth %s"), - quote (optarg)); - ok = false; - } - } - break; - - case 'm': - human_output_opts = 0; - output_block_size = 1024 * 1024; - break; - - case 'l': - opt_count_all = true; - break; - - case 's': - opt_summarize_only = true; - break; - - case 't': - { - enum strtol_error e; - e = xstrtoimax (optarg, NULL, 0, &opt_threshold, "kKmMGTPEZY0"); - if (e != LONGINT_OK) - xstrtol_fatal (e, oi, c, long_options, optarg); - if (opt_threshold == 0 && *optarg == '-') - { - /* Do not allow -0, as this wouldn't make sense anyway. */ - die (EXIT_FAILURE, 0, _("invalid --threshold argument '-0'")); - } - } - break; - - case 'x': - bit_flags |= FTS_XDEV; - break; - - case 'B': - { - enum strtol_error e = human_options (optarg, &human_output_opts, - &output_block_size); - if (e != LONGINT_OK) - xstrtol_fatal (e, oi, c, long_options, optarg); - } - break; - - case 'H': /* NOTE: before 2008-12, -H was equivalent to --si. */ - case 'D': - symlink_deref_bits = FTS_COMFOLLOW | FTS_PHYSICAL; - break; - - case 'L': /* --dereference */ - symlink_deref_bits = FTS_LOGICAL; - break; - - case 'P': /* --no-dereference */ - symlink_deref_bits = FTS_PHYSICAL; - break; - - case 'S': - opt_separate_dirs = true; - break; - - case 'X': - if (add_exclude_file (add_exclude, exclude, optarg, - EXCLUDE_WILDCARDS, '\n')) - { - error (0, errno, "%s", quotef (optarg)); - ok = false; - } - break; - - case FILES0_FROM_OPTION: - files_from = optarg; - break; - - case EXCLUDE_OPTION: - add_exclude (exclude, optarg, EXCLUDE_WILDCARDS); - break; - - case INODES_OPTION: - opt_inodes = true; - break; - - case TIME_OPTION: - opt_time = true; - time_type = - (optarg - ? XARGMATCH ("--time", optarg, time_args, time_types) - : time_mtime); - localtz = tzalloc (getenv ("TZ")); - break; - - case TIME_STYLE_OPTION: - time_style = optarg; - break; - - case_GETOPT_HELP_CHAR; - - case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS); - - default: - ok = false; - } - } - - if (!ok) - usage (EXIT_FAILURE); - - if (opt_all && opt_summarize_only) - { - error (0, 0, _("cannot both summarize and show all entries")); - usage (EXIT_FAILURE); - } - - if (opt_summarize_only && max_depth_specified && max_depth == 0) - { - error (0, 0, - _("warning: summarizing is the same as using --max-depth=0")); - } - - if (opt_summarize_only && max_depth_specified && max_depth != 0) - { - unsigned long int d = max_depth; - error (0, 0, _("warning: summarizing conflicts with --max-depth=%lu"), d); - usage (EXIT_FAILURE); - } - - if (opt_summarize_only) - max_depth = 0; - - if (opt_inodes) - { - if (apparent_size) - { - error (0, 0, _("warning: options --apparent-size and -b are " - "ineffective with --inodes")); - } - output_block_size = 1; - } - - /* Process time style if printing last times. */ - if (opt_time) - { - if (! time_style) - { - time_style = getenv ("TIME_STYLE"); - - /* Ignore TIMESTYLE="locale", for compatibility with ls. */ - if (! time_style || STREQ (time_style, "locale")) - time_style = "long-iso"; - else if (*time_style == '+') - { - /* Ignore anything after a newline, for compatibility - with ls. */ - char *p = strchr (time_style, '\n'); - if (p) - *p = '\0'; - } - else - { - /* Ignore "posix-" prefix, for compatibility with ls. */ - static char const posix_prefix[] = "posix-"; - static const size_t prefix_len = sizeof posix_prefix - 1; - while (STREQ_LEN (time_style, posix_prefix, prefix_len)) - time_style += prefix_len; - } - } - - if (*time_style == '+') - time_format = time_style + 1; - else - { - switch (XARGMATCH ("time style", time_style, - time_style_args, time_style_types)) - { - case full_iso_time_style: - time_format = "%Y-%m-%d %H:%M:%S.%N %z"; - break; - - case long_iso_time_style: - time_format = "%Y-%m-%d %H:%M"; - break; - - case iso_time_style: - time_format = "%Y-%m-%d"; - break; - } - } - } - - struct argv_iterator *ai; - if (files_from) - { - /* When using --files0-from=F, you may not specify any files - on the command-line. */ - if (optind < argc) - { - error (0, 0, _("extra operand %s"), quote (argv[optind])); - fprintf (stderr, "%s\n", - _("file operands cannot be combined with --files0-from")); - usage (EXIT_FAILURE); - } - - if (! (STREQ (files_from, "-") || freopen (files_from, "r", stdin))) - die (EXIT_FAILURE, errno, _("cannot open %s for reading"), - quoteaf (files_from)); - - ai = argv_iter_init_stream (stdin); - - /* It's not easy here to count the arguments, so assume the - worst. */ - hash_all = true; - } - else - { - char **files = (optind < argc ? argv + optind : cwd_only); - ai = argv_iter_init_argv (files); - - /* Hash all dev,ino pairs if there are multiple arguments, or if - following non-command-line symlinks, because in either case a - file with just one hard link might be seen more than once. */ - hash_all = (optind + 1 < argc || symlink_deref_bits == FTS_LOGICAL); - } - - if (!ai) - xalloc_die (); - - /* Initialize the set of dev,inode pairs. */ - di_files = di_set_alloc (); - if (!di_files) - xalloc_die (); - - /* If not hashing everything, process_file won't find cycles on its - own, so ask fts_read to check for them accurately. */ - if (opt_count_all || ! hash_all) - bit_flags |= FTS_TIGHT_CYCLE_CHECK; - - bit_flags |= symlink_deref_bits; - static char *temp_argv[] = { NULL, NULL }; - - while (true) - { - bool skip_file = false; - enum argv_iter_err ai_err; - char *file_name = argv_iter (ai, &ai_err); - if (!file_name) - { - switch (ai_err) - { - case AI_ERR_EOF: - goto argv_iter_done; - case AI_ERR_READ: - error (0, errno, _("%s: read error"), - quotef (files_from)); - ok = false; - goto argv_iter_done; - case AI_ERR_MEM: - xalloc_die (); - default: - assert (!"unexpected error code from argv_iter"); - } - } - if (files_from && STREQ (files_from, "-") && STREQ (file_name, "-")) - { - /* Give a better diagnostic in an unusual case: - printf - | du --files0-from=- */ - error (0, 0, _("when reading file names from stdin, " - "no file name of %s allowed"), - quoteaf (file_name)); - skip_file = true; - } - - /* Report and skip any empty file names before invoking fts. - This works around a glitch in fts, which fails immediately - (without looking at the other file names) when given an empty - file name. */ - if (!file_name[0]) - { - /* Diagnose a zero-length file name. When it's one - among many, knowing the record number may help. - FIXME: currently print the record number only with - --files0-from=FILE. Maybe do it for argv, too? */ - if (files_from == NULL) - error (0, 0, "%s", _("invalid zero-length file name")); - else - { - /* Using the standard 'filename:line-number:' prefix here is - not totally appropriate, since NUL is the separator, not NL, - but it might be better than nothing. */ - unsigned long int file_number = argv_iter_n_args (ai); - error (0, 0, "%s:%lu: %s", quotef (files_from), - file_number, _("invalid zero-length file name")); - } - skip_file = true; - } - - if (skip_file) - ok = false; - else - { - temp_argv[0] = file_name; - ok &= du_files (temp_argv, bit_flags); - } - } - argv_iter_done: - - argv_iter_free (ai); - di_set_free (di_files); - if (di_mnt) - di_set_free (di_mnt); - - if (files_from && (ferror (stdin) || fclose (stdin) != 0) && ok) - die (EXIT_FAILURE, 0, _("error reading %s"), quoteaf (files_from)); - - if (print_grand_total) - print_size (&tot_dui, _("total")); - - return ok ? EXIT_SUCCESS : EXIT_FAILURE; -} - diff --git a/scripts/health/health.c b/scripts/health/health.c deleted file mode 100644 index 2c00478..0000000 --- a/scripts/health/health.c +++ /dev/null @@ -1,220 +0,0 @@ -#define DEBUG - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "health.h" -#include "utils.h" - -//ustring ok_str = NEW_USTRING("OK"); -//ustring warn_str = NEW_USTRING("WARN"); -//ustring arrow_str = NEW_USTRING("├─"); -//ustring arrow_last_str = NEW_USTRING("└─"); -ustring ok_str = {.str = "OK", .bytes = strlen("OK") }; -ustring warn_str = {.str = "WARN ☠", .bytes = strlen("WARN ☠")}; -ustring arrow_str = {.str = "├─", .bytes = strlen("├─")}; -ustring arrow_last_str = {.str ="└─", .bytes = strlen("└─")}; - -// fts_path doesn't append trailing slash -struct dir_status top_dir_var[] = { - WATCH_DIR("/var/cache", "1.5G"), - WATCH_DIR("/var/log", "0.5G") -}; - -struct dir_status top_dir_home[] = { - WATCH_DIR("/home/kuba/.cache", "3G"), - WATCH_DIR("/home/kuba/Downloads", "1G") -}; - -struct dir_status top_dir_usr[] = { - WATCH_DIR("/usr/local", "5G"), - WATCH_DIR("/usr/lib", "5G"), - WATCH_DIR("/usr/share", "5G"), - WATCH_DIR("/usr/bin", "1G") -}; - -struct dir_status watched_dirs[] = { - WATCH_DIR_SUBS("/var", "2.5G", top_dir_var), - WATCH_DIR_SUBS("/home/kuba", "20G", top_dir_home), - WATCH_DIR_SUBS("/usr", "15G", top_dir_usr), - WATCH_DIR("/boot", "80M"), - WATCH_DIR("/etc", "20M"), - WATCH_DIR("/root", "10M"), - WATCH_DIR("/run", "10M"), - WATCH_DIR("/srv", "1M"), - WATCH_DIR("/opt", "1G") -}; - -int main(int argc, char* const argv[]) -{ - INIT_USTRING(ok_str); - INIT_USTRING(warn_str); - INIT_USTRING(arrow_str); - INIT_USTRING(arrow_last_str); - // Traverse top directories and do some nice formatting - char buf[80]; - for (int i = 0; i < sizeof(watched_dirs)/sizeof(struct dir_status); i++){ - struct dir_status *dir = watched_dirs + i; - disk_usage(dir); - - format_directory_entry(buf, dir, 0, 0); - } - exit(0); - - if (argc<2) - { - printf("Usage: %s \n", argv[0]); - exit(255); - } - - return 0; -} - - -//Maybe just remove this, the effect is not noticable -off_t traverse_nochildren(FTS *file_system, const short dir_level) -{ - FTSENT *node = NULL; - struct stat *st = NULL; - off_t tot_size = 0; - - while( (node = fts_read(file_system)) != NULL) - { - // Add to size - st = node->fts_statp; - if (st) tot_size += (off_t) 512*st->st_blocks; - else debug("st null pointer, skipping\n"); - - if (node->fts_info == FTS_DP) - { - indent_debug(node->fts_level); - debug("Exiting %s\n", node->fts_path); - // Directory being visited in post-order. Only action is to - // return if back at the starting level - if (node->fts_level == dir_level) return tot_size; - } - } - return 0;// This is bad -} - -void traverse_children(FTS *file_system, struct dir_status *dir, const short dir_level) -{ - FTSENT *node = NULL; - struct stat *st = NULL; - off_t tot_size = 0; - - top_loop:while( (node = fts_read(file_system)) != NULL) - { - //indent_debug(node->fts_level); - //debug("%s\n", node->fts_name); - if (node->fts_info == FTS_D) - { - if(strcmp(node->fts_path, dir->path) == 0) { - continue; // Do nothing - } - indent_debug(node->fts_level); - debug("Entering %s\n", node->fts_path); - // Directory being visited in pre-order. Do not count size except - // after returning from a recursion step. Determine if the current - // node is one of the children. - for (int i = 0; i < dir->n_children; i++) { - struct dir_status *sub_dir = dir->children+i; - if(strcmp(node->fts_path, sub_dir->path) == 0){ - // Entering one of the child-directories - indent_debug(node->fts_level); - debug("Entering special %s\n", node->fts_path); - traverse_children(file_system, sub_dir, node->fts_level); - tot_size += sub_dir->size; - goto top_loop; - } - } - // Child directory not in list, call traverse_nochildren instead - tot_size += traverse_nochildren(file_system, node->fts_level); - continue; // Does the same as goto above - } - - // Add to size - st = node->fts_statp; - if (st) tot_size += (off_t) 512*st->st_blocks; - else debug("st null pointer, skipping\n"); - - if (node->fts_info == FTS_DP) - { - indent_debug(node->fts_level); - debug("Exiting %s\n", node->fts_path); - // Directory being visited in post-order. Only action is to save - // size and return if back at the starting level - if (node->fts_level == dir_level){ - dir->size = tot_size; - return; - } - } - } -} - -int disk_usage(struct dir_status *top_dir) -{ - char *paths[] = { top_dir->path, NULL}; - FTS* file_system = NULL; - - file_system = fts_open(paths, FTS_PHYSICAL, NULL); - - if (file_system == NULL) return 1; - - traverse_children(file_system, top_dir, 0); - - fts_close(file_system); - return 0; -} - -const int max_length = 60; -const int max_path_length = 40; -void format_directory_entry(char *buf, struct dir_status *dir, int level, int last_subdir) -{ - int n = 0; //Keeps track of where in buffer we are - int delta_n = 0; // Keeps track of how much shorter the string appears - // than the number of bytes - - // First fill with apropriate amount of spaces and └ or ├ charcters - if (level > 0) { - ustring *arr = last_subdir?&arrow_last_str:&arrow_str; - - n = 4*level - arr->chars; - delta_n += arr->chars - arr->bytes; - memset(buf, ' ', n); - strncpy(buf+n, arr->str, arr->bytes); - n += arr->bytes; - } - - // Path and size - n += snprintf(buf + n, max_path_length, "%s -- ", dir->path); - n += pretty_bytes(buf + n, dir->size); - memset(buf + n, ' ', max_length - n); // max_length - n for simplicity - - // Right-justify WARN or OK status - ustring *ok = directory_ok(dir->size, dir->warn_at)?&ok_str:&warn_str; - delta_n += ok->chars - ok->bytes; - snprintf(buf + max_length - ok->bytes - 2 - delta_n, ok->bytes+2 - , "%s\n", ok->str);// 2 leaves space for \n and null - printf("%s", buf); - - // Loop through children - for (int i = 0; i < dir->n_children; i++){ - int last = (i == dir->n_children - 1); - format_directory_entry(buf, dir->children + i, (level + 1), last); - } - - if(level == 0) printf("\n"); -} -int directory_ok(off_t size, char *warn_at){ - off_t warn = pretty_bytes_to_num(warn_at); - return size < warn; -} - diff --git a/scripts/health/health.h b/scripts/health/health.h deleted file mode 100644 index ca0a198..0000000 --- a/scripts/health/health.h +++ /dev/null @@ -1,43 +0,0 @@ -#ifndef HEALTH_H -#define HEALTH_H - -#include -#include "utils.h" - -/* - * path - Path of the directory without trailing slash - * warn_at - How large is the directory allowed to be before a warning is - * issued. In human readable form (see utils.c:pretty_bytes) - * children - List of all watched sub-directories - * n_children - Number of elements in children - * size - Size of directory, this is filled in by disk_usage() - */ -struct dir_status { - char * const path; - char * const warn_at; - struct dir_status *children; - int n_children; - off_t size; -}; - -#define WATCH_DIR(pth,wrn) {.path = pth, .warn_at = wrn, .n_children=0, .size=0} -#define WATCH_DIR_SUBS(pth,wrn,subs) {.path = pth, .warn_at = wrn, .size=0 \ - , .children=subs, .n_children=sizeof(subs)/sizeof(struct dir_status)} - -off_t traverse_nochildren(FTS *file_system, const short dir_level); -void traverse_children(FTS *file_system, struct dir_status *dir, const short dir_level); -int disk_usage(struct dir_status *top_dir); - -//ustring ok_ustr = {.str = "OK", .bytes = 2, .chars = 2}; -//NEW_USTRING(ok_str, "OK"); -//NEW_USTRING(warn_str, "WARN"); -//NEW_USTRING(arrow_str, "├─"); -//NEW_USTRING(arrow_last_str,"└─"); -//INIT_USTRING(ok_str); -//INIT_USTRING(warn_str); -//INIT_USTRING(arrow_str); -//INIT_USTRING(arrow_last_str); -void format_directory_entry(char *buf, struct dir_status *dir, int level, int last_subdir); -int directory_ok(off_t size, char *warn_at); - -#endif diff --git a/scripts/health/makefile b/scripts/health/makefile deleted file mode 100755 index b25e3e4..0000000 --- a/scripts/health/makefile +++ /dev/null @@ -1,24 +0,0 @@ -CFLAGS = -Wall -LDFLAGS = -lm -CC = gcc - -default: health - -optim: CFLAGS += -O3 -optim: health - -debug: CFLAGS += -g -debug: health - -OBJECTS=health.o utils.o -health: $(OBJECTS) - $(CC) $(CFLAGS) -o health $(OBJECTS) $(LDFLAGS) - -health.o: health.c health.h - $(CC) $(CFLAGS) -c health.c - -utils.o: utils.c utils.h - $(CC) $(CFLAGS) -c utils.c - -clean: - rm -f *.o diff --git a/scripts/health/utils.c b/scripts/health/utils.c deleted file mode 100644 index fc4d9d8..0000000 --- a/scripts/health/utils.c +++ /dev/null @@ -1,87 +0,0 @@ -#include -#include -#include -#include - -#include "utils.h" - - -void indent(int i) -{ - for (; i > 0; i--) printf(" "); -} - - -// Prints to the provided buffer a nice number of bytes (KB, MB, GB, etc) -// Returns bytes written -int pretty_bytes(char* buf, long long bytes) -{ - const char* suffixes[7]; - suffixes[0] = "B"; - suffixes[1] = "KB"; - suffixes[2] = "MB"; - suffixes[3] = "GB"; - suffixes[4] = "TB"; - suffixes[5] = "PB"; - suffixes[6] = "EB"; - uint s = 0; // which suffix to use - double count = bytes; - while (count >= 1024 && s < 7) - { - s++; - count /= 1024; - } - if (count - floor(count) == 0.0) - return sprintf(buf, "%d %s", (int)count, suffixes[s]); - else - return sprintf(buf, "%.1f %s", count, suffixes[s]); -} - -long long pretty_bytes_to_num(char* buf) -{ - // First letter of suffix in order - const char suffixes[7] = {'B', 'K', 'M', 'G', 'T', 'P', 'E'}; - char suffix; - float fnum; - long long num = 1; - int n; - - errno = 0; - n = sscanf(buf,"%f%c", &fnum, &suffix); - if (n == 2) { - //TODO error handling - } else if (errno != 0) { - perror("scanf"); - } else { - fprintf(stderr, "No matching characters\n"); - } - - for (int s=0;s -#include - -size_t utf8len(const char *s); - -typedef struct { - const char *str; - const size_t bytes; - size_t chars; -} ustring; - - -#define NEW_USTRING(string) {.str = string, .bytes = strlen(string)}//; varname.chars=utf8len(string)} -#define INIT_USTRING(varname) (varname).chars = utf8len(varname.str) - -long long pretty_bytes_to_num(char* buf); -int pretty_bytes(char* buf, long long bytes); -void debug(const char *format, ...); -void indent (int i); -void indent_debug (int i); - -#endif diff --git a/scripts/healthy-disk-usage b/scripts/healthy-disk-usage new file mode 160000 index 0000000..41fb87b --- /dev/null +++ b/scripts/healthy-disk-usage @@ -0,0 +1 @@ +Subproject commit 41fb87beb782010e21f0587eb51da00a34b93256 diff --git a/scripts/set_bg.sh b/scripts/set_bg.sh deleted file mode 100755 index e469a9b..0000000 --- a/scripts/set_bg.sh +++ /dev/null @@ -1,24 +0,0 @@ -#!/bin/bash -#function get_index(){ -# for i in "${!xra_out[@]}"; do -# if [[ "${xra_out[$i]}" = "$value" ]]; then -# echo "${i}"; -# break -# fi -# done -#} -#xra_out=($(xrandr | grep ' connected' | awk '{print $1}')) -#in=($@) -#for i in `seq 0 2 ${#in[@]}`; do -# value="${in[$i]}" -# idx=$(get_index) -# if [ ! -z "$idx" ]; then -# screen_idx="$idx" -# #"${xra_out[$idx-1]}" -# paths[${screen_idx%:}]="--bg-scale ${in[$i+1]}" -# fi -#done -##echo "${paths[@]}" -#str=`printf -v var "%s\n" "${System[@]}"` -#sh -c "feh ${paths[@]}" -feh --bg-scale "$@"