anifetch-cli 1.0.1__tar.gz → 1.0.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: anifetch-cli
3
- Version: 1.0.1
3
+ Version: 1.0.2
4
4
  Summary: Animated terminal fetch with video and audio support.
5
5
  Author-email: Notenlish <notenlish@gmail.com>
6
6
  Maintainer: Immelancholy
@@ -265,6 +265,12 @@ _Note : by default, the video `example.mp4` can directly be used as an example._
265
265
  - `--quality`: Changes the output quality of ffmpeg when extracting frames. This doesn't have much effect on the quality or speed from my testing, so you shouldn't need to change this. 2 highest quality, 10 lowest quality.
266
266
  - `--loop`: Determines how many times the animation should loop. Default is -1(always loop).
267
267
  - `--no-key-exit`: Don't exit anifetch when user presses a key.
268
+ - `-c` / `--config`: Specify a non-default config for Neofetch/Fastfetch.
269
+ - Accepts a path or preset name (e.g. `main`).
270
+ - Neofetch (Linux/macOS): `~/.config/neofetch/main.conf`
271
+ - Fastfetch (Linux/macOS): `~/.config/fastfetch/main.jsonc`
272
+ - Fastfetch (Windows): `%APPDATA%\fastfetch\main.jsonc`
273
+ - See [Customizing Fastfetch/Neofetch](#customizing-fastfetchneofetch-output) for config details.
268
274
 
269
275
  ### Cached files:
270
276
 
@@ -238,6 +238,12 @@ _Note : by default, the video `example.mp4` can directly be used as an example._
238
238
  - `--quality`: Changes the output quality of ffmpeg when extracting frames. This doesn't have much effect on the quality or speed from my testing, so you shouldn't need to change this. 2 highest quality, 10 lowest quality.
239
239
  - `--loop`: Determines how many times the animation should loop. Default is -1(always loop).
240
240
  - `--no-key-exit`: Don't exit anifetch when user presses a key.
241
+ - `-c` / `--config`: Specify a non-default config for Neofetch/Fastfetch.
242
+ - Accepts a path or preset name (e.g. `main`).
243
+ - Neofetch (Linux/macOS): `~/.config/neofetch/main.conf`
244
+ - Fastfetch (Linux/macOS): `~/.config/fastfetch/main.jsonc`
245
+ - Fastfetch (Windows): `%APPDATA%\fastfetch\main.jsonc`
246
+ - See [Customizing Fastfetch/Neofetch](#customizing-fastfetchneofetch-output) for config details.
241
247
 
242
248
  ### Cached files:
243
249
 
@@ -24,7 +24,7 @@ keywords = [
24
24
  "fastfetch",
25
25
  "anifetch",
26
26
  ]
27
- version = "1.0.1"
27
+ version = "1.0.2"
28
28
  description = "Animated terminal fetch with video and audio support."
29
29
  # If I put everyone here it messes with the "author" meta section.
30
30
  authors = [{ name = "Notenlish", email = "notenlish@gmail.com" }]
@@ -75,7 +75,6 @@ parser.add_argument(
75
75
  help="Disabled by default. Anifetch saves the filename to check if the file has changed, if the name is same, it won't render it again. If enabled, the video will be forcefully rendered, whether it has the same name or not. Please note that it only checks for filename, if you changed the framerate then you'll need to force render.",
76
76
  )
77
77
  parser.add_argument(
78
- "-C",
79
78
  "--center",
80
79
  default=False,
81
80
  action="store_true",
@@ -160,6 +159,7 @@ parser.add_argument(
160
159
  help="Delete one or more caches by number(s) (as listed with --cache-list)",
161
160
  )
162
161
  parser.add_argument(
162
+ "-C",
163
163
  "--clear",
164
164
  required=False,
165
165
  action="store_true",
@@ -174,6 +174,19 @@ parser.add_argument(
174
174
  action="store_true",
175
175
  )
176
176
 
177
+ parser.add_argument(
178
+ "-c",
179
+ "--config",
180
+ default="",
181
+ help="Specify non-default config file for Neofetch/Fastfetch. Use a path or a preset name.\n"
182
+ "Examples:\n"
183
+ "- Linux/macOS:\n"
184
+ " - Neofetch: 'main' → ~/.config/neofetch/main.conf\n"
185
+ " - Fastfetch: 'main' → ~/.config/fastfetch/main.jsonc\n"
186
+ "- Windows:\n"
187
+ " - Fastfetch: 'main' → %%APPDATA%%\\fastfetch\\main.jsonc",
188
+ )
189
+
177
190
 
178
191
  def parse_args():
179
192
  return parser.parse_args()
@@ -232,7 +232,7 @@ def run_anifetch(args):
232
232
 
233
233
  # Get the fetch output(neofetch/fastfetch)
234
234
  fetch_output: list[str] = get_fetch_output(
235
- not args.neofetch, neofetch_status, args.force
235
+ not args.neofetch, neofetch_status, args.force, args.config
236
236
  )
237
237
 
238
238
  # copy fetch_output to fetch_lines
@@ -314,8 +314,6 @@ def run_anifetch(args):
314
314
 
315
315
  cleaned_dict["sound_saved_path"] = args.sound_saved_path
316
316
 
317
- cleaned_dict["sound_saved_path"] = args.sound_saved_path
318
-
319
317
  print_verbose(should_print_verbose, args.sound_saved_path)
320
318
 
321
319
  # If the new anim frames is shorter than the old one, then in /output there will be both new and old frames.
@@ -234,6 +234,7 @@ def strip_ansi(text):
234
234
  def get_text_length_of_formatted_text(text: str):
235
235
  text = strip_ansi(text)
236
236
  return len(text)
237
+ # return get_character_width(text)
237
238
 
238
239
 
239
240
  def get_ext_from_codec(codec):
@@ -354,16 +355,41 @@ def get_fetch_output(
354
355
  use_fastfetch: bool,
355
356
  neofetch_status: Literal["neofetch", "uninstalled", "wrapper"],
356
357
  force_neofetch: bool,
358
+ config_file: str,
357
359
  ):
358
360
  fetch_output: list[str]
361
+
359
362
  if not use_fastfetch: # use neofetch
360
363
  if (
361
364
  neofetch_status == "wrapper" and force_neofetch
362
365
  ) or neofetch_status == "neofetch":
363
366
  # Get Neofetch Output
364
- fetch_output = subprocess.check_output(
365
- ["neofetch", "--off"], text=True
366
- ).splitlines()
367
+
368
+ output: list = ["neofetch", "--off"]
369
+ if config_file:
370
+ if config_file.endswith(
371
+ ".conf"
372
+ ): # if user input config path directly (~/.config/neofetch/custom.conf or /home/user/custom.conf etc.)
373
+ if not Path(config_file).exists():
374
+ print(
375
+ f"Config file {config_file} not found. Make sure the path is correct.",
376
+ file=sys.stderr,
377
+ )
378
+ sys.exit(1)
379
+ else: # if user input a preset name, look for it in ~/.config/neofetch/{preset_name}.conf
380
+ config_file = str(
381
+ Path.home() / ".config/neofetch" / f"{config_file}.conf"
382
+ )
383
+ if not Path(config_file).exists():
384
+ print(
385
+ f"Config file {config_file} not found. Make sure the preset name is correct and the corresponding config file exists in ~/.config/neofetch/.",
386
+ file=sys.stderr,
387
+ )
388
+ sys.exit(1)
389
+ output += ["--config", config_file]
390
+ # print(output)
391
+
392
+ fetch_output = subprocess.check_output(output, text=True).splitlines()
367
393
 
368
394
  elif neofetch_status == "uninstalled":
369
395
  print(
@@ -378,11 +404,35 @@ def get_fetch_output(
378
404
  file=sys.stderr,
379
405
  )
380
406
  sys.exit(1)
381
- else:
407
+ else: # use fastfetch
382
408
  try:
383
- fetch_output = subprocess.check_output(
384
- ["fastfetch", "--logo", "none", "--pipe", "false"], text=True
385
- ).splitlines()
409
+ output: list = ["fastfetch", "--logo", "none", "--pipe", "false"]
410
+ if config_file:
411
+ if config_file.endswith(
412
+ ".jsonc"
413
+ ): # if user input config path directly (~/.config/fastfetch/custom.jsonc or /home/user/custom.jsonc)
414
+ if not Path(config_file).exists():
415
+ print(
416
+ f"Config file {config_file} not found. Make sure the path is correct.",
417
+ file=sys.stderr,
418
+ )
419
+ sys.exit(1)
420
+
421
+ # this part is actually optional because fastfetch have built in tools like this but this is for checking valid config
422
+ else: # if user input a preset name, look for it in ~/.config/fastfetch/{preset_name}.jsonc
423
+ config_file = str(
424
+ Path.home() / ".config/fastfetch" / f"{config_file}.jsonc"
425
+ )
426
+ if not Path(config_file).exists():
427
+ print(
428
+ f"Config file {config_file} not found. Make sure the preset name is correct and the corresponding config file exists in ~/.config/fastfetch/.",
429
+ file=sys.stderr,
430
+ )
431
+ sys.exit(1)
432
+ output += ["--config", config_file]
433
+
434
+ fetch_output = subprocess.check_output(output, text=True).splitlines()
435
+
386
436
  except FileNotFoundError as e:
387
437
  if e.errno == errno.ENOENT:
388
438
  print(
@@ -411,6 +461,7 @@ def make_template_from_fetch_lines(
411
461
  template: list[str] = "\n".join(fetch_lines)
412
462
  # Only do this once instead of for every line.
413
463
  template_actual_width = get_text_length_of_formatted_text(fetch_lines[0])
464
+ # template_actual_width = max((get_text_length_of_formatted_text(line) for line in fetch_lines), default=0)
414
465
  return (template, template_actual_width)
415
466
 
416
467
 
@@ -481,6 +532,7 @@ def clean_cache_args(cache_args: dict) -> dict:
481
532
  "center",
482
533
  "loop",
483
534
  "no_key_exit",
535
+ "config",
484
536
  )
485
537
  cleaned = deepcopy(cache_args) # need to deepcopy to not modify original dict.
486
538
  for key in args_to_remove:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: anifetch-cli
3
- Version: 1.0.1
3
+ Version: 1.0.2
4
4
  Summary: Animated terminal fetch with video and audio support.
5
5
  Author-email: Notenlish <notenlish@gmail.com>
6
6
  Maintainer: Immelancholy
@@ -265,6 +265,12 @@ _Note : by default, the video `example.mp4` can directly be used as an example._
265
265
  - `--quality`: Changes the output quality of ffmpeg when extracting frames. This doesn't have much effect on the quality or speed from my testing, so you shouldn't need to change this. 2 highest quality, 10 lowest quality.
266
266
  - `--loop`: Determines how many times the animation should loop. Default is -1(always loop).
267
267
  - `--no-key-exit`: Don't exit anifetch when user presses a key.
268
+ - `-c` / `--config`: Specify a non-default config for Neofetch/Fastfetch.
269
+ - Accepts a path or preset name (e.g. `main`).
270
+ - Neofetch (Linux/macOS): `~/.config/neofetch/main.conf`
271
+ - Fastfetch (Linux/macOS): `~/.config/fastfetch/main.jsonc`
272
+ - Fastfetch (Windows): `%APPDATA%\fastfetch\main.jsonc`
273
+ - See [Customizing Fastfetch/Neofetch](#customizing-fastfetchneofetch-output) for config details.
268
274
 
269
275
  ### Cached files:
270
276
 
File without changes
File without changes