66//! - `aur` for Arch based system
77//! - `dnf` for Fedora based system
88//! - `xbps` for Void Linux
9+ //! - `apk` for Alpine Linux
910//!
1011//! # Configuration
1112//!
3031//! `aur` | Number of updates available in Arch based system | Number | -
3132//! `dnf` | Number of updates available in Fedora based system | Number | -
3233//! `xbps` | Number of updates available in Void Linux | Number | -
34+ //! `apk` | Number of updates available in Alpine Linux | Number | -
3335//! `total` | Number of updates available in all package manager listed | Number | -
3436//!
3537//! # Apt
174176//! cmd = "xbps-install -Mun | dmenu -l 10"
175177//! ```
176178//!
179+ //!
180+ //! Apk only config:
181+ //!
182+ //! ```toml
183+ //! [[block]]
184+ //! block = "packages"
185+ //! package_manager = ["apk"]
186+ //! interval = 1800
187+ //! error_interval = 300
188+ //! max_retries = 5
189+ //! format = " $icon $apk.eng(w:1) updates available "
190+ //! format_singular = " $icon One update available "
191+ //! format_up_to_date = " $icon system up to date "
192+ //! [[block.click]]
193+ //! # shows dmenu with available updates. Any dmenu alternative should also work.
194+ //! button = "left"
195+ //! cmd = "apk --no-cache --upgradable list | dmenu -l 10"
196+ //! ```
197+ //!
177198//! Multiple package managers config:
178199//!
179200//! Update the list of pending updates every thirty minutes (1800 seconds):
180201//!
181202//! ```toml
182203//! [[block]]
183204//! block = "packages"
184- //! package_manager = ["apt", "pacman", "aur", "dnf", "xbps"]
205+ //! package_manager = ["apt", "pacman", "aur", "dnf", "xbps", "apk" ]
185206//! interval = 1800
186207//! error_interval = 300
187208//! max_retries = 5
188- //! format = " $icon $apt + $pacman + $aur + $dnf + $xbps = $total updates available "
209+ //! format = " $icon $apt + $pacman + $aur + $dnf + $xbps + $apk = $total updates available "
189210//! format_singular = " $icon One update available "
190211//! format_up_to_date = " $icon system up to date "
191212//! # If a linux update is available, but no ZFS package, it won't be possible to
@@ -212,6 +233,9 @@ use dnf::Dnf;
212233pub mod xbps;
213234use xbps:: Xbps ;
214235
236+ pub mod apk;
237+ use apk:: Apk ;
238+
215239use regex:: Regex ;
216240
217241use super :: prelude:: * ;
@@ -240,6 +264,7 @@ pub enum PackageManager {
240264 Aur ,
241265 Dnf ,
242266 Xbps ,
267+ Apk ,
243268}
244269
245270pub async fn run ( config : & Config , api : & CommonApi ) -> Result < ( ) > {
@@ -267,6 +292,7 @@ pub async fn run(config: &Config, api: &CommonApi) -> Result<()> {
267292 let pacman = any_format_contains ! ( "pacman" ) ;
268293 let dnf = any_format_contains ! ( "dnf" ) ;
269294 let xbps = any_format_contains ! ( "xbps" ) ;
295+ let apk = any_format_contains ! ( "apk" ) ;
270296
271297 if !config. package_manager . contains ( & PackageManager :: Apt ) && apt {
272298 config. package_manager . push ( PackageManager :: Apt ) ;
@@ -283,6 +309,9 @@ pub async fn run(config: &Config, api: &CommonApi) -> Result<()> {
283309 if !config. package_manager . contains ( & PackageManager :: Xbps ) && xbps {
284310 config. package_manager . push ( PackageManager :: Xbps ) ;
285311 }
312+ if !config. package_manager . contains ( & PackageManager :: Apk ) && apk {
313+ config. package_manager . push ( PackageManager :: Apk ) ;
314+ }
286315
287316 let warning_updates_regex = config
288317 . warning_updates_regex
@@ -314,6 +343,7 @@ pub async fn run(config: &Config, api: &CommonApi) -> Result<()> {
314343 ) ) ,
315344 PackageManager :: Dnf => Box :: new ( Dnf :: new ( ) ) ,
316345 PackageManager :: Xbps => Box :: new ( Xbps :: new ( ) ) ,
346+ PackageManager :: Apk => Box :: new ( Apk :: new ( ) ) ,
317347 } ) ;
318348 }
319349
0 commit comments