├── .gitignore ├── README.md └── pridefetch /.gitignore: -------------------------------------------------------------------------------- 1 | __pycache__ 2 | 3 | # Remove emacs tilde files 4 | .gitignore~ 5 | pridefetch~ 6 | README.md~ -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # pridefetch 2 | Neofetch clone written in Python with the ability to display pride flags 3 | 4 | ## Examples 5 | ### Display a trans flag 6 | `pridefetch -f trans` 7 | 8 | ### Display either a trans or lesbian flag, with a 50/50 chance 9 | `pridefetch -c trans, lesbian` 10 | 11 | ### List all the available flags 12 | `pridefetch -l` -------------------------------------------------------------------------------- /pridefetch: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | import argparse 4 | import distro 5 | import random 6 | from getpass import getuser 7 | from socket import gethostname 8 | from time import strftime 9 | from time import gmtime 10 | from subprocess import run 11 | 12 | # Define a dictionary of all the flags and their colors 13 | # Each color is the color for an individual row in the flag 14 | flags = { 15 | 'straight': [0, 255, 0, 255, 0], 16 | 'gay': [196, 208, 226, 28, 20, 90], 17 | 'bisexual': [198, 198, 97, 25, 25], 18 | 'lesbian': [202, 209, 255, 255, 168, 161], 19 | 'pansexual': [198, 198, 220, 220, 39, 39], 20 | 'trans': [81, 211, 255, 211, 81], 21 | 'nonbinary': [226, 226, 255, 255, 98, 98, 237, 237], 22 | 'demiboy': [244, 249, 117, 255, 117, 249, 244], 23 | 'demigirl': [244, 249, 218, 255, 218, 249, 244], 24 | 'genderfluid': [211, 255, 128, 0, 63], 25 | 'aromantic': [71, 149, 255, 249, 0], 26 | 'agender': [0, 251, 255, 149, 255, 251, 0], 27 | 'asexual': [0, 0, 242, 242, 255, 255, 54, 54], 28 | 'graysexual': [54, 242, 255, 242, 54], 29 | } 30 | 31 | def color256(col, bg_fg): 32 | # Hacky alias around manually typing out escape codes every time 33 | return f'\033[{48 if bg_fg == "bg" else 38};5;{col}m' 34 | 35 | def draw_info(flag_name): 36 | if not flag_name in flags: 37 | print("Flag not found") 38 | return 39 | 40 | box = ' ' 41 | width = 20 42 | 43 | flag = flags[flag_name] 44 | curr_row = 0 45 | 46 | # Store the output of uname -srm 47 | uname_info = run(['uname', '-srm'], capture_output=True) 48 | uname_info = uname_info.stdout.decode().strip() 49 | 50 | # Make sure that the row color is different to the color of the hostname 51 | row_color = color256(flag[1] if flag[0] != flag[1] else flag[2], "fg") 52 | 53 | reset = '\033[0m\033[39m' 54 | 55 | print() 56 | for row in flag: 57 | # Alternate displaying the information based on the current row 58 | if curr_row == 0: 59 | color = color256(flag[curr_row], "fg") 60 | 61 | user = getuser() 62 | host = gethostname() 63 | row_info = f'{color}\033[1m{user}@{host}{reset}' 64 | elif curr_row == 1: 65 | distribution = distro.name() 66 | row_info = f'{row_color}os {reset}{distribution or "N/A"}' 67 | elif curr_row == 2: 68 | arch = uname_info.split(' ')[2] 69 | row_info = f'{row_color}arch {reset}{arch}' 70 | elif curr_row == 3: 71 | kernel = uname_info.split(' ')[1] 72 | row_info = f'{row_color}kern {reset}{kernel}' 73 | elif curr_row == 4: 74 | uptime = run(['uptime'], capture_output=True) 75 | time = uptime.stdout.decode().split(" ")[1] 76 | 77 | row_info = f'{row_color}uptime {reset}{time}' 78 | else: 79 | row_info = '' 80 | 81 | if row != 'P': 82 | print(f' {color256(row, "bg")}{box * width}\033[49m {row_info}') 83 | else: 84 | # Print just the info, along with the padding for the box 85 | print(f' {box * width}\033[49m {row_info}') 86 | 87 | curr_row += 1 88 | 89 | print() 90 | 91 | def main(): 92 | parser = argparse.ArgumentParser() 93 | parser.add_argument('-f', '--flag', help='Displays the chosen FLAG') 94 | parser.add_argument('-c', '--choose', help='Choose a flag at random from this list') 95 | parser.add_argument('-l', '--list', action='store_true', help='Lists all the flags') 96 | 97 | args = parser.parse_args() 98 | 99 | if args.flag: 100 | draw_info(args.flag) 101 | 102 | if args.choose: 103 | # Choose a flag at random from a list of comma-seperated flags 104 | flag_choices = args.choose.split(',') 105 | draw_info(random.choice(flag_choices)) 106 | 107 | if args.list: 108 | # List out all the available flags 109 | print('Available flags:') 110 | print(', '.join(flags)) 111 | 112 | 113 | 114 | if __name__ == '__main__': 115 | main() 116 | --------------------------------------------------------------------------------