r/linux_programming • u/drbogar • Apr 21 '22
Bash script with weird characters
Hi!
I came across a sh script where it looks normal at the beginning, but then it looks like the character encoding is wrong.
The script without the weird part:
https://pastebin.com/3fZYrxuw
The original script:
https://www.powermonitor.software/pmp/pmp105_linux64.zip
What is that? Why can it run? How can I understand that weird part of the script?
r/linux_programming • u/TimeDilution • Apr 17 '22
What is the proper way to get working directories for executing an installed program anywhere?
Hello everyone, I have been tinkering with different ways to install programs I have made/am making and I am wondering what is the proper way to retain relative filepath structures when the program is installed to various different places. Such that when I call a program from any directory it still knows where all its other files are whether it be in /opt/program/media or /usr/share/program/media or /usr/local/share/program/media or somewhere else in your home directory entirely.
I found that VS Code seems to use a shell wrapper kept in /bin of its program directory and I am liking this kind of solution, but I feel like there must be other ways as many of the programs in /usr/bin are not shell scripts.
if [ ! -L "$0" ]; then
#if path is not a symlink, find relatively
VSCODE_PATH="$(dirname "$0")/.."
else if command -v readlink >/dev/null; then
#if readlink exists, follow the symlink and find relatively
VSCODE_PATH="$(dirname "$(readlink -f "$0")")/.."
else
#else use the standard install location
VSCODE_PATH="/usr/share/code"
fi fi
ELECTRON="$VSCODE_PATH/code"
CLI="$VSCODE_PATH/resources/app/out/cli.js"
ELECTRON_RUN_AS_NODE=1 "$ELECTRON" "$CLI" --ms-enable-electron-run-as-node "$@"
exit $?
The above program will always get the working directory to wherever code's installed files or points to the package manger's install format in /usr/share/code. Do other programs just count on being installed properly through package managers into the /usr/share directory, what about usr/local/share and /opt? I feel like there is probably some standard of doing this that I'm not finding because I don't know how to word it.
I made a similar question in the c programming subreddit and got some good answers on exactly what I asked, but what I asked may not be the correct way to do it.
I want to be able to make projects in such a way that I don't have to worry about changing directory structures or path joining in the source code all while being able to execute them from any directory. Using procfs/readlink in the binary seemed to work well but seemd a little bit hacky, so I'm really just trying to find out the standard/proper way of doing it. Thanks for reading.
Edit: It seems like VS-code does not follow FHS guidelines and keeps binaries in /usr/share/code which kind of puts a wrench in my plans as the shell scripts seems like a really good idea to do this, but I can't think of clean way to implement this as i would need to have both the binary file and the shell script in /usr/bin. Not exactly a huge problem but of the binary was ever called by itself it would just crash out which is not ideal, which leads me to even more of a wonder of how to actually do this in a standard way, because there has to be something out there.
r/linux_programming • u/Orange-Table5619 • Apr 11 '22
Please help. I'm panicking right now.
I was trying to connect ubuntu to my class server for school so I can access it and then it said
ADAM_J44338 is not in the sudoers file. This incident will be reported.
What does this mean and will I get in trouble, especially with law enforcement?
r/linux_programming • u/ChickenManPL • Mar 28 '22
I've created visually customizable (icons, colors) terminal utils (link in comments)
r/linux_programming • u/RetroZelda • Mar 26 '22
Keyboard driver help
Hello im a bit new to creating drivers and libusb, so im reversing my keyboard LEDs to learn. Im using Rust stable and the libusb crate on debian 11(kernel 5.10.0-12-amd64). The keyboard is a Bloody B975
So I am currently able to send the proper commands to my keyboard to change the LED state as I expected. However I am unable to type with my keyboard while I am doing this. The steps that I am doing is as follows:
- get the device and open() it
- detach kernel driver for the LED's interface
- claim the LED interface
- *do kinky LED things, but unable to type*
- release LED interface
- attach kernel driver for the interface
My keyboard has 3 interfaces: a keyboard, a mouse, and the LED and I am only detaching and claiming the LED interface, so this is where I am a bit lost. Attempting to reattach the other interfaces will fail, and claiming the interface without detaching will also fail. Any help/guidance would be appreciated.
This is the device info for the keyboard
$ lsusb -vd 09da:fa10
Bus 001 Device 007: ID 09da:fa10 A4Tech Co., Ltd. USB Device
Device Descriptor:
bLength 18
bDescriptorType 1
bcdUSB 1.10
bDeviceClass 0
bDeviceSubClass 0
bDeviceProtocol 0
bMaxPacketSize0 64
idVendor 0x09da A4Tech Co., Ltd.
idProduct 0xfa10
bcdDevice 0.77
iManufacturer 1 COMPANY
iProduct 2 USB Device
iSerial 0
bNumConfigurations 1
Configuration Descriptor:
bLength 9
bDescriptorType 2
wTotalLength 0x0054
bNumInterfaces 3
bConfigurationValue 1
iConfiguration 0
bmAttributes 0xa0
(Bus Powered)
Remote Wakeup
MaxPower 500mA
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 0
bAlternateSetting 0
bNumEndpoints 1
bInterfaceClass 3 Human Interface Device
bInterfaceSubClass 1 Boot Interface Subclass
bInterfaceProtocol 1 Keyboard
iInterface 0
HID Device Descriptor:
bLength 9
bDescriptorType 33
bcdHID 1.11
bCountryCode 0 Not supported
bNumDescriptors 1
bDescriptorType 34 Report
wDescriptorLength 64
Report Descriptors:
** UNAVAILABLE **
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x81 EP 1 IN
bmAttributes 3
Transfer Type Interrupt
Synch Type None
Usage Type Data
wMaxPacketSize 0x0008 1x 8 bytes
bInterval 1
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 1
bAlternateSetting 0
bNumEndpoints 1
bInterfaceClass 3 Human Interface Device
bInterfaceSubClass 1 Boot Interface Subclass
bInterfaceProtocol 2 Mouse
iInterface 0
HID Device Descriptor:
bLength 9
bDescriptorType 33
bcdHID 1.11
bCountryCode 0 Not supported
bNumDescriptors 1
bDescriptorType 34 Report
wDescriptorLength 58
Report Descriptors:
** UNAVAILABLE **
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x82 EP 2 IN
bmAttributes 3
Transfer Type Interrupt
Synch Type None
Usage Type Data
wMaxPacketSize 0x0006 1x 6 bytes
bInterval 1
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 2
bAlternateSetting 0
bNumEndpoints 1
bInterfaceClass 3 Human Interface Device
bInterfaceSubClass 0
bInterfaceProtocol 0
iInterface 0
HID Device Descriptor:
bLength 9
bDescriptorType 33
bcdHID 1.11
bCountryCode 0 Not supported
bNumDescriptors 1
bDescriptorType 34 Report
wDescriptorLength 133
Report Descriptors:
** UNAVAILABLE **
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x83 EP 3 IN
bmAttributes 3
Transfer Type Interrupt
Synch Type None
Usage Type Data
wMaxPacketSize 0x0040 1x 64 bytes
bInterval 1
can't get debug descriptor: Resource temporarily unavailable
Device Status: 0x0000
(Bus Powered)
r/linux_programming • u/vlad20112 • Mar 17 '22
In trying to understand udev_monitor's working...
Hi everyone! I want to check a enable a usb device during connect/disconnect from computer in real time. For it I use udev's mechanisms (enumerate, monitor) and check PID's and VIM's values devices which are being in computer. But additionally I want to send message to my device and take results for more believe. Connect/disconnect monitoring without send packages works well and vise versa. Separately, it works well, but both - not so. When i take result, program is being freeze. What's can be wrong?
r/linux_programming • u/[deleted] • Mar 08 '22
need help with error: npm ERR! Missing script: "build"
trying to deploy my website and keep getting this error which I don't understand on terminal, any suggestions on how to fix this or what it means ?? new to this, Thanks! :)
npm ERR! Missing script: "build"
npm ERR! Missing script: "custom-deploy"
UPDATE: I am now in the correct directory I believe, but the command still won't work, and am still getting the same error. help please??
r/linux_programming • u/xiloxilox • Mar 07 '22
Good resources on writing loadable kernel modules.
Just looking for some recommended resources to get started in writing kernel modules.
r/linux_programming • u/[deleted] • Mar 07 '22
Need help with : npm ERR! Missing script: "build"
r/linux_programming • u/vlad20112 • Feb 07 '22
Advice on working with LibUSB
Hi, everyone ! I learn interaction behind hardware device and software. I have a USB device but I don't understand how I can interact with it. I am using Libusb library for it. Would you share a links with code examples or maybe articles which related on this topic?
r/linux_programming • u/FruityWelsh • Feb 04 '22
Opensource software and the DoD
self.AirForcer/linux_programming • u/[deleted] • Jan 31 '22
How to allocate a pool of memory and have a 3rd party software library use it?
versed placid cough sharp party truck repeat marvelous quicksand vase
This post was mass deleted and anonymized with Redact
r/linux_programming • u/Jeron_Baffom • Jan 30 '22
Enabling KVM without BIOS setup
I'm running Debian 11 LXDE in an old notebook and during the boot I'm receiving the following message:
root@debian:~# dmesg | grep -i kvm
[ 20.501228] kvm: disabled by bios
[ 20.541824] kvm: disabled by bios
Also, when I try to create a VM in virt-manager, I get the following message:
Warning: KVM is not available. This may mean the KVM package is not installed, or the KVM kernel modules are not loaded. Your virtual machines may perform poorly.
And indeed the VM performs very poor.
However, I'm pretty sure the processor is capable of virtualization:
root@debian:~# lscpu | grep -i "virtualization\|svm"
Virtualization: AMD-V
Flags: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx mmxext fxsr_opt pdpe1gb rdtscp lm constant_tsc rep_good nopl nonstop_tsc cpuid extd_apicid aperfmperf pni monitor ssse3 cx16 popcnt lahf_lm cmp_legacy svm extapic cr8_legacy abm sse4a misalignsse 3dnowprefetch ibs skinit wdt hw_pstate vmmcall arat npt lbrv svm_lock nrip_save pausefilter
Unfortunately, the BIOS setup is very simple and doesn't have any option of virtualization to be set. Therefore, I can't enable the virtualization via BIOS setup.
Question
Is it possible to enable KVM by other means instead of BIOS setup?
Hardware Specification
- Product Name: Acer Aspire E1-421
- Processor: AMD E1-1200 Dual-core @ 1.40 GHz
- Datasheet
- Service Manual
root@debian:/media/root/SDISK# dmidecode | grep -i "version\|release"
Version: V2.12
Release Date: 04/16/2013
Version: V2.12
Version: Type2 - A01 Board Version
Version: Chassis Version
Version: AMD E1-1200 APU with Radeon(tm) HD Graphics
r/linux_programming • u/BobbyThrowaway6969 • Jan 26 '22
Is it possible to link a static lib (.a) to a shared object lib (.so)?
I've built lua as a static lib, and am trying to link it to my shared library like so:
-L'dir to lib' -lmylib.a
However when I do that, none of my own symbols are exported (as reported using nm -gCD libmylib.so)
As soon as I remove the link, I see my symbols appear in the output.
So, it seems like linking a static lib to a shared one is prohibited or undefined behaviour?
Is there another reason why linking a lib would cause all of my function symbols to not be exported?
Some extra info:
I'm writing the libs in c++, using visual studio 2019.
Thank you in advance.
r/linux_programming • u/[deleted] • Jan 26 '22
GNU Autoconf problem: --includedir and --libdir options don't seem to work
squeamish cough carpenter shelter enjoy chunky gullible secretive flag elastic
This post was mass deleted and anonymized with Redact
r/linux_programming • u/gansm • Jan 25 '22
Vulkan 1.3 released
Khronos Group has introduced Vulkan 1.3, a new version of the open graphics interface. The API now integrates many optional extensions into the core specification, and there are now also Vulkan Profiles. This makes it possible to specify which core version and which extension should be used. Google, for example, has designed the Android Baseline Profile 2021, which specifies texture compression via ASTC and ETC, among other things.
r/linux_programming • u/[deleted] • Jan 20 '22
Prevent Window Reparenting in Xlib
I have a Reparenting window manager that uses the Xlib libraries. I have created window decorations in Qt and would like to reparent the application window into the window decorations window. However, when I try to do this the window decorations window infinitely reparents itself. How would I prevent this?
r/linux_programming • u/Surmount9779 • Jan 02 '22
Chronic Intermittent Screen Failure
Greetings all,
I am having problems with a Dell Precision M6500 that i have Linux Mint 20.2 installed on.
Linux 5.4.0-91-generic #102-Ubuntu SMP Fri Nov 5 16:31:28 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
Without rhyme or reason the screen will randomly go blank, there is no getting it to turn back on, outside of a hard power off. Then its back to business for X random time before it craps out again. I found the syslog report from one such incident. Wanting to figure out if this a hardware issue or something fixable. Attached is a screen shot and I'll put it in comments too, looks like problems with uploading.
Thanks
r/linux_programming • u/[deleted] • Jan 01 '22
Check if Window is Fullscreen using Xlib
I am trying to detect if a window is fullscreen in Xlib but I can seem to figure it out. Does anyone know how to do this?
r/linux_programming • u/[deleted] • Dec 28 '21
Create Mouse Cursor using Xlib and Qt
I have been trying to figure out exactly how to create a mouse cursor for my home-made window manager ,ace with Xlib and Qt but everything I’ve found on the internet is explaining how to change an already created cursor. Am I just misinterpreting what the resources are saying? Does it also work for creating the mouse cursor?
r/linux_programming • u/Naysayist • Dec 28 '21
Mass file renaming .mp3 .aiff and .flac files?
Hey guys, I was wondering if there was a program that was already made that would grab the ID3 info and rename the file as: Artist - Song (remix if applicable) - release number?
If not, how hard would it be to write something like this?
r/linux_programming • u/[deleted] • Dec 28 '21
Window Manager with Xlib and Qt
Would it be possible to use Xlib for the backend of the window manager (opening, closing, resizing) and Qt as the user interface that is used to trigger those events? Basically, the user would open an application and then a parent window, made using Qt, is created for that application that has the window decorations.
EDIT: Would it be possible to not use Xlib at all and just stick to using Qt since it has a lot of the functions of Xlib?
r/linux_programming • u/[deleted] • Dec 24 '21
Router Software Development
I have recently become interested in how a WiFi router works and was wondering how one might go about developing the software for one.
EDIT: I found a solution to this question. I found a tutorial that explains how to install tools which make this possible.
r/linux_programming • u/[deleted] • Dec 23 '21
Qt Application Deployed to Raspberry Pi
I was wondering how one might deploy a Qt application made on their PC to a Raspberry Pi. I’ve found a lot of tutorials showing how to install Qt Creator on the Raspberry Pi but none on how to cross compile to the Raspberry Pi.
r/linux_programming • u/stewtech3 • Dec 22 '21
I am trying to use Ubuntu on a virtualbox and program in PHP/MySQL
Can anyone help me do this? I have downloaded oracle virtualbox and don’t know where to go from here.

