this post was submitted on 22 Apr 2024
33 points (92.3% liked)
Linux
48352 readers
575 users here now
From Wikipedia, the free encyclopedia
Linux is a family of open source Unix-like operating systems based on the Linux kernel, an operating system kernel first released on September 17, 1991 by Linus Torvalds. Linux is typically packaged in a Linux distribution (or distro for short).
Distributions include the Linux kernel and supporting system software and libraries, many of which are provided by the GNU Project. Many Linux distributions use the word "Linux" in their name, but the Free Software Foundation uses the name GNU/Linux to emphasize the importance of GNU software, causing some controversy.
Rules
- Posts must be relevant to operating systems running the Linux kernel. GNU/Linux or otherwise.
- No misinformation
- No NSFW content
- No hate speech, bigotry, etc
Related Communities
Community icon by Alpár-Etele Méder, licensed under CC BY 3.0
founded 5 years ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
Thx! I could enable/disable bluetooth with your commands and that didn't solve my problem, but helped me google the right command. It is actually much simpler that I thought, I just had to find speakers MAC and I can use:
bluetoothctl connect A1:11:22:3A:CD:F1
Now working on mapping that to a key, cheers!
You could also run the command automatically every time your screen is unlocked depending on your DE. For instance, if you use GNOME, this will likely work
EDIT: see comment below for better solution
Thank you! I use GNOME, but this is kinda confusing tbh. I was also looking at this forum post where I should put a script in
/lib/systemd/system-sleep/
. I should play around with that, but can't afford breaking system right now xD. Will try it soon, I might install separate OS just for testingEDIT: Previous answer was distro dependent and had a syntax error. I have replaced it with the following instructions.
Create 2 files
bluetooth-reconnect.sh
andbluetooth-reconnect.service
. Using your favorite text editor, edit these files so they will contain the following:bluetooth-reconnect.sh
bluetooth-reconnect.service
Open a terminal in whatever location you created them (you can right click in your file manager and open in terminal, or use
cd
to navigate). Now move them to the correct locations (you will need sudo privilege for this):Make the script executable:
Enable and start the service:
Check to make sure the service started correctly (the "Active:" field should say "active (running)" in green.
This should now do everything automatically. This has been tested and is working on my Fedora Workstation system (uses GNOME). This should be distro independent, unlike my previous answer (and also without the syntax error I had in my initial submission).
To uninstall:
Thank you a lot mate for explaining in detail. I will deffo go that route
While trying to test this on my system, I came across a few issues. I found a more modern and standardized way to check for login after sleep, and have updated my previous comment with a new script. I have new instructions though that are more comprehensive that you can follow.
Create 2 files
bluetooth-reconnect.sh
andbluetooth-reconnect.service
. Using your favorite text editor, edit these files so they will contain the following:bluetooth-reconnect.sh
bluetooth-reconnect.service
Open a terminal in whatever location you created them (you can right click in your file manager and open in terminal, or use
cd
to navigate). Now move them to the correct locations (you will need sudo privilege for this):Make the script executable:
Enable and start the service:
Check to make sure the service started correctly (the "Active:" field should say "active (running)" in green).
This should now do everything automatically. This has been tested and is working on my Fedora Workstation system (uses GNOME). This should be distro independent, unlike my previous answer (and also without the syntax error I had in my initial submission).
To uninstall:
Dude this is amazing. Working like a charm and I love linux even more because of you <3 Such a straightforward guide. Have a wonderful day my friend!
One of the wonderful things about Linux is that if something isn't working, you can just make it work! Also, if you ever need to make a simple service to run a script on boot, you know how now; it can be very useful. Always happy to help though, enjoy your journey through Linux!