scripts and other
This commit is contained in:
parent
3d6c11e8c1
commit
adc4db6b55
6 changed files with 63 additions and 4 deletions
29
local/bin/usbmount
Normal file
29
local/bin/usbmount
Normal file
|
@ -0,0 +1,29 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
import os
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
RED = "\033[0;31m"
|
||||
RESET = "\033[0m"
|
||||
|
||||
def main():
|
||||
if os.geteuid() != 0:
|
||||
print(f"{RED}[!] Superuser access is required{RESET}")
|
||||
sys.exit(1)
|
||||
|
||||
if not os.path.exists("/dev/sda"):
|
||||
print(f"{RED}[!] USB not found!{RESET}")
|
||||
sys.exit(1)
|
||||
|
||||
print(f"{RED}[*] Decrypting /dev/sda1...{RESET}")
|
||||
try:
|
||||
subprocess.run(["cryptsetup", "open", "/dev/sda1", "sda1_crypt"], check=True)
|
||||
subprocess.run(["mount", "/dev/mapper/sda1_crypt", "/mnt/usb", "--mkdir"], check=True)
|
||||
print(f"{RED}[*] Decrypted and mounted to /mnt/usb!{RESET}")
|
||||
except subprocess.CalledProcessError as e:
|
||||
print(f"{RED}[!] Error: {e}{RESET}")
|
||||
sys.exit(1)
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
31
local/bin/usbumount
Normal file
31
local/bin/usbumount
Normal file
|
@ -0,0 +1,31 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
import os
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
RED = "\033[0;31m"
|
||||
RESET = "\033[0m"
|
||||
|
||||
def run(cmd, fail_msg):
|
||||
try:
|
||||
subprocess.run(cmd, check=True)
|
||||
except subprocess.CalledProcessError:
|
||||
print(f"{RED}[!] {fail_msg}{RESET}")
|
||||
sys.exit(1)
|
||||
|
||||
def main():
|
||||
if os.geteuid() != 0:
|
||||
print(f"{RED}[!] Superuser access is required{RESET}")
|
||||
sys.exit(1)
|
||||
|
||||
print(f"{RED}[*] Unmounting /mnt/usb...{RESET}")
|
||||
run(["umount", "/mnt/usb"], "Failed to unmount /mnt/usb")
|
||||
|
||||
print(f"{RED}[*] Closing encrypted device...{RESET}")
|
||||
run(["cryptsetup", "close", "sda1_crypt"], "Failed to close mapper device")
|
||||
|
||||
print(f"{RED}[*] Unmounted and closed successfully!{RESET}")
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
/* See LICENSE file for copyright and license details. */
|
||||
|
||||
/* appearance */
|
||||
|
|
|
@ -65,7 +65,7 @@ static const char unknown_str[] = "n/a";
|
|||
*/
|
||||
static const struct arg args[] = {
|
||||
/* function format argument */
|
||||
{run_command, " [ %s%] ", "pamixer --get-volume"},
|
||||
{run_command, "[ %s%]", "amixer get Master | grep -o '[0-9]*%' | head -1"},
|
||||
{ram_used, " [ %s] ", NULL},
|
||||
{battery_state, "[%s", "BAT1"},
|
||||
{battery_perc, " %s%] ", "BAT1"},
|
||||
|
|
Binary file not shown.
Binary file not shown.
Loading…
Add table
Reference in a new issue