1414//! `format_up_to_date` | Same as `format`, but for when no updates are available. | `" $icon $count.eng(w:1) "`
1515//! `warning_updates_regex` | Display block as warning if updates matching regex are available. | `None`
1616//! `critical_updates_regex` | Display block as critical if updates matching regex are available. | `None`
17+ //! `ignore_updates_regex` | Doesn't include updates matching regex in the count. | `None`
1718//! `ignore_phased_updates` | Doesn't include potentially held back phased updates in the count. | `false`
1819//!
1920//! Placeholder | Value | Type | Unit
@@ -67,6 +68,7 @@ pub struct Config {
6768 pub format_up_to_date : FormatConfig ,
6869 pub warning_updates_regex : Option < String > ,
6970 pub critical_updates_regex : Option < String > ,
71+ pub ignore_updates_regex : Option < String > ,
7072 pub ignore_phased_updates : bool ,
7173}
7274
@@ -91,6 +93,12 @@ pub async fn run(config: &Config, api: &CommonApi) -> Result<()> {
9193 . map ( Regex :: new)
9294 . transpose ( )
9395 . error ( "invalid critical updates regex" ) ?;
96+ let ignore_updates_regex = config
97+ . ignore_updates_regex
98+ . as_deref ( )
99+ . map ( Regex :: new)
100+ . transpose ( )
101+ . error ( "invalid ignore updates regex" ) ?;
94102
95103 let mut cache_dir = env:: temp_dir ( ) ;
96104 cache_dir. push ( "i3rs-apt" ) ;
@@ -124,7 +132,13 @@ pub async fn run(config: &Config, api: &CommonApi) -> Result<()> {
124132 loop {
125133 let mut widget = Widget :: new ( ) ;
126134 let updates = get_updates_list ( config_file) . await ?;
127- let count = get_update_count ( config_file, config. ignore_phased_updates , & updates) . await ?;
135+ let count = get_update_count (
136+ config_file,
137+ config. ignore_phased_updates ,
138+ ignore_updates_regex. as_ref ( ) ,
139+ & updates,
140+ )
141+ . await ?;
128142
129143 widget. set_format ( match count {
130144 0 => format_up_to_date. clone ( ) ,
@@ -189,11 +203,16 @@ async fn get_updates_list(config_path: &str) -> Result<String> {
189203async fn get_update_count (
190204 config_path : & str ,
191205 ignore_phased_updates : bool ,
206+ ignore_updates_regex : Option < & Regex > ,
192207 updates : & str ,
193208) -> Result < usize > {
194209 let mut cnt = 0 ;
195210
196- for update_line in updates. lines ( ) . filter ( |line| line. contains ( "[upgradable" ) ) {
211+ for update_line in updates
212+ . lines ( )
213+ . filter ( |line| line. contains ( "[upgradable" ) )
214+ . filter ( |line| ignore_updates_regex. map_or ( true , |re| !re. is_match ( line) ) )
215+ {
197216 if !ignore_phased_updates || !is_phased_update ( config_path, update_line) . await ? {
198217 cnt += 1 ;
199218 }
0 commit comments