# grub2_music_maker.cpp - takes a MIDI file as input, converts it to text notes, and writes it to GRUB_INIT_TUNE in /etc/default/grub -- V1.0 #include #include #include int main(int argc, char *argv[]) { if (argc < 2) { std::cout << "Usage: " << argv[0] << " " << std::endl; return 1; } std::ifstream midiFile(argv[1], std::ios::binary); if (!midiFile.is_open()) { std::cerr << "Error opening MIDI file" << std::endl; return 1; } // Read MIDI file and convert to plain text notes std::vector notes; char note; while (midiFile.read(¬e, 1)) { notes.push_back(note); } // Save notes to the GRUB2 bootloader std::ofstream grubFile("/etc/default/grub"); if (!grubFile.is_open()) { std::cerr << "Error opening GRUB file" << std::endl; return 1; } grubFile << "GRUB_INIT_TUNE=\""; for (const char& n : notes) { grubFile << n; } grubFile << "\"" << std::endl; std::cout << "MIDI file converted to plain text notes and saved to GRUB2 bootloader" << std::endl; return 0; }