From ad83e5a63a506827738913a9c4bef77d780613c6 Mon Sep 17 00:00:00 2001 From: Fabio Scotto di Santolo Date: Sun, 7 Sep 2025 22:32:39 +0200 Subject: [PATCH] Added clipboard manager and fix battery module on Polybar --- i3/.config/i3/config | 25 ++-- i3/.config/i3/scripts/poweroff.sh | 11 +- i3/.config/polybar/config.ini | 2 +- i3/.config/polybar/modules.ini | 132 +++++++++++++++++++- i3/.config/polybar/scripts/battery_combo.sh | 21 ++++ 5 files changed, 175 insertions(+), 16 deletions(-) create mode 100755 i3/.config/polybar/scripts/battery_combo.sh diff --git a/i3/.config/i3/config b/i3/.config/i3/config index 05bd73b..9f94568 100644 --- a/i3/.config/i3/config +++ b/i3/.config/i3/config @@ -19,6 +19,10 @@ set $right l set $term 'alacritty' set $editor 'emacs' +set $filemanager 'nemo' +set $notification 'dunst' +set $browser 'org.mozilla.firefox' +set $clipboard 'diodon' # Define names for default workspaces for which we configure key bindings later on. # We use variables to avoid repeating the names in multiple places. @@ -113,12 +117,13 @@ for_window [class="Webconsole"] floating enable for_window [class="Authy"] floating enable for_window [class="Termfloat"] floating enable, resize set 960 540 for_window [class="Mpv"] floating enable, resize set 960 540 -for_window [class="Spotify"] floating enable, move scratchpad +for_window [class="Spotify"] floating enable, resize set 1280 1024, move scratchpad # Workspaces assign [class="Emacs"] 1 assign [class="firefox"] 2 assign [class="Telegram"] 3 +assign [class="discord"] 3 focus_follows_mouse no @@ -151,10 +156,11 @@ mode "launcher" { } bindsym $mod+d mode "launcher" +bindsym $mod+Shift+f exec "nemo" bindsym $mod+Shift+b exec "flatpak run org.mozilla.firefox" bindsym $mod+Shift+t exec "flatpak run org.telegram.desktop" bindsym Print exec flameshot gui -# bindsym $mod+Shift+v exec xfce4-clipman-history +bindsym $mod+Shift+v exec --no-startup-id $clipboard # Use pactl to adjust volume in PulseAudio. bindsym XF86AudioRaiseVolume exec --no-startup-id pactl set-sink-volume @DEFAULT_SINK@ +5% @@ -312,19 +318,21 @@ exec --no-startup-id xss-lock --transfer-sleep-lock -- i3lock --nofork exec --no-startup-id nm-applet # Polkit Authentication agent -exec --no-startup-id /usr/lib/policykit-1-gnome/polkit-gnome-authentication-agent-1 +exec_always --no-startup-id /usr/lib/policykit-1-gnome/polkit-gnome-authentication-agent-1 ### Apply wallpaper -exec_always feh --bg-scale ~/.config/i3/wallpaper.jpg +exec_always --no-startup-id feh --bg-scale ~/.config/i3/wallpaper.jpg ### Run status bar -exec_always ~/.config/polybar/launch.sh +exec_always --no-startup-id ~/.config/polybar/launch.sh ### Run in background X11 compositor -exec_always picom --config ~/.config/picom/picom.conf +exec_always --no-startup-id picom --config ~/.config/picom/picom.conf ### Run in background notification daemon -exec_always $notification +exec_always --no-startup-id $notification + +exec --no-startup-id $clipboard ### Enable autolock exec_always xautolock -time 5 -locker ~/.config/i3/scripts/lockscreen.sh -detectsleep @@ -334,3 +342,6 @@ exec flameshot ### Run my preferred editor exec $editor + +### Run my preferred browser +exec flatpak run $browser \ No newline at end of file diff --git a/i3/.config/i3/scripts/poweroff.sh b/i3/.config/i3/scripts/poweroff.sh index d2066ca..1ace738 100755 --- a/i3/.config/i3/scripts/poweroff.sh +++ b/i3/.config/i3/scripts/poweroff.sh @@ -1,13 +1,12 @@ #!/bin/bash -# Menu di power con rofi -chosen=$(echo -e "⏻ Spegni\n Riavvia\n Logout\n Sospendi\n Iberna" | rofi -dmenu -p "Power Menu:" -theme-str 'window {width: 20%;}') +chosen=$(echo -e "⏻ Shutdown\n Restart\n Logout\n Suspend\n Hibernate" | rofi -dmenu -p "Power Menu:" -theme-str 'window {width: 20%;}') case "$chosen" in - "⏻ Spegni") systemctl poweroff ;; - " Riavvia") systemctl reboot ;; + "⏻ Shutdown") systemctl poweroff ;; + " Restart") systemctl reboot ;; " Logout") loginctl terminate-session $XDG_SESSION_ID ;; - " Sospendi") systemctl suspend ;; - " Iberna") systemctl hibernate ;; + " Suspend") systemctl suspend ;; + " Hibernate") systemctl hibernate ;; *) exit 0 ;; esac diff --git a/i3/.config/polybar/config.ini b/i3/.config/polybar/config.ini index 5565acd..179a098 100644 --- a/i3/.config/polybar/config.ini +++ b/i3/.config/polybar/config.ini @@ -121,7 +121,7 @@ font-0 = "JetBrainsMono Nerd Font:size=12;2" ; modules-right = ipc clock modules-left = xworkspaces modules-center = -modules-right = spotify filesystem memory cpu pulseaudio backlight battery xkeyboard date systray +modules-right = spotify filesystem memory cpu pulseaudio backlight battery0 battery1 xkeyboard date systray ; Value to be used to set the WM_NAME atom ; If the value is empty or undefined, the atom value diff --git a/i3/.config/polybar/modules.ini b/i3/.config/polybar/modules.ini index a72fe4d..d51ac7b 100644 --- a/i3/.config/polybar/modules.ini +++ b/i3/.config/polybar/modules.ini @@ -66,7 +66,7 @@ type = internal/memory interval = 2 format-prefix = " " format-prefix-foreground = ${colors.teal} -label = %percentage_used:2%% +label = %gb_used%/%gb_total% [module/cpu] type = internal/cpu @@ -100,7 +100,7 @@ date-alt = %Y-%m-%d %H:%M:%S label = %date% ;label-foreground = ${colors.blue} -[module/battery] +[module/battery0] type = internal/battery ; This is useful in case the battery never reports 100% charge @@ -191,7 +191,135 @@ format-low-foreground = ${colors.red} ; %percentage_raw% ; %time% ; %consumption% (shows current discharge rate in watts) +; New in versinon 3.6.0 +; label-low = BATTERY LOW + +; Only applies if is used +ramp-capacity-0 =  +ramp-capacity-1 =  +ramp-capacity-2 =  +ramp-capacity-3 =  +ramp-capacity-4 =  + +; Only applies if is used +bar-capacity-width = 10 + +; Only applies if is used +animation-charging-0 =  +animation-charging-1 =  +animation-charging-2 =  +animation-charging-3 =  +animation-charging-4 =  +; Framerate in milliseconds +animation-charging-framerate = 750 + +; Only applies if is used +animation-discharging-0 =  +animation-discharging-1 =  +animation-discharging-2 =  +animation-discharging-3 =  +animation-discharging-4 =  +; Framerate in milliseconds +animation-discharging-framerate = 500 + +; Only applies if is used ; New in version 3.6.0 +;animation-low-0 = ! +;animation-low-1 = +;animation-low-framerate = 200 + +[module/battery1] +type = internal/battery + +; This is useful in case the battery never reports 100% charge +; Default: 100 +full-at = 100 + +; format-low once this charge percentage is reached +; Default: 10 +; New in version 3.6.0 +low-at = 20 + +; Use the following command to list batteries and adapters: +; $ ls -1 /sys/class/power_supply/ +battery = BAT1 +adapter = ADP1 + +; If an inotify event haven't been reported in this many +; seconds, manually poll for new values. +; +; Needed as a fallback for systems that don't report events +; on sysfs/procfs. +; +; Disable polling by setting the interval to 0. +; +; Default: 5 +poll-interval = 5 + +; see "man date" for details on how to format the time string +; NOTE: if you want to use syntax tags here you need to use %%{...} +; Default: %H:%M:%S +time-format = %H:%M + +; Available tags: +; (default) +; +; +; +format-charging = +animation-charging-foreground = ${colors.green} + +; Available tags: +; (default) +; +; +; +format-discharging = +ramp-capacity-foreground = ${colors.yellow} + +; Available tags: +; (default) +; +; +format-full = +format-full-foreground = ${colors.green} + +; Format used when battery level drops to low-at +; If not defined, format-discharging is used instead. +; Available tags: +; +; +; +; +; New in version 3.6.0 +format-low = +format-low-foreground = ${colors.red} + +; Available tokens: +; %percentage% (default) - is set to 100 if full-at is reached +; %percentage_raw% +; %time% +; %consumption% (shows current charge rate in watts) +;label-charging = Charging %percentage%% + +; Available tokens: +; %percentage% (default) - is set to 100 if full-at is reached +; %percentage_raw% +; %time% +; %consumption% (shows current discharge rate in watts) +;label-discharging = Discharging %percentage%% + +; Available tokens: +; %percentage% (default) - is set to 100 if full-at is reached +; %percentage_raw% +;label-full = Fully charged + +; Available tokens: +; %percentage% (default) - is set to 100 if full-at is reached +; %percentage_raw% +; %time% +; %consumption% (shows current discharge rate in watts) +; New in versinon 3.6.0 ; label-low = BATTERY LOW ; Only applies if is used diff --git a/i3/.config/polybar/scripts/battery_combo.sh b/i3/.config/polybar/scripts/battery_combo.sh new file mode 100755 index 0000000..064662c --- /dev/null +++ b/i3/.config/polybar/scripts/battery_combo.sh @@ -0,0 +1,21 @@ +#!/bin/bash + +# Paths to battery capacity files +battery0_capacity="/sys/class/power_supply/BAT0/capacity" +battery1_capacity="/sys/class/power_supply/BAT1/capacity" + +# Check if the capacity files exist +if [[ -f "$battery0_capacity" && -f "$battery1_capacity" ]]; then + # Read the battery percentages + battery0_charge=$(cat "$battery0_capacity") + battery1_charge=$(cat "$battery1_capacity") + + # Calculate the average charge + average_charge=$(( (battery0_charge + battery1_charge) / 2 )) + + # Print the average percentage + echo "$average_charge%" +else + # If one of the files is missing, print an error + echo "Error: one or more battery capacity files not found." +fi