Okay, so during the Italio-Turkish war the Ottoman Empire put a ton of effort into guerrilla resistance against the Italians in Lybia, to the point where one resistance group, the Senussi (which was technically a religious order, but like, they also functioned as a resistance group) was still fighting against the Italians during WW2, long after the Ottoman Empire had ceased to exist.
However, when the Dey of Algeria upset the French enough that the French invaded, the Ottoman Empire just declared Algeria independent and let the French do as they pleased. Likewise, when the French marched into Tunis, the Ottoman Empire just pretended they were an "autonomous province" and ignored the de facto reality that France had literally invaded the Empire.
Anyway, what made Lybia so special? Why did the Ottoman Empire care so much more about that one patch of north african desert than they did about the other two?
I'll try to answer your answer, sorry if it doesn't satisfy you (Because i too, don't know much and would very glad if some expert fill this in)
About Algeria and Tunis being an independent province, it's actually right. During the 18th century, local janissary officers in Tripoli (Libya), Algiers (Algeria), and Tunis (Tunisia) all seized control of the governorship of their respective cities and established hereditary dynasties, with their descendants succeeding them as governors into the nineteenth century. The Porte all recognized their rule as a vassal state, but they were largely independent. This is because as 16th century passed by, the importance of the Western Mediterranean for the Ottoman Empire declined and as early as the 17th century the North African province had become autonomous. The Porte, generally also considered the North African provinces as unimportant compared to other regions. They rarely appeared in Ottoman court chronicles and one time, when local Algerian janissaries refused a governor sent by the Ottomans, Grand Vizier Köprülü Mehmed Pasa responded like this:
Well then, a vali [governor] will not be sent to you. You may pledge allegiance to whoever you like. The Padisah [sultan] has no need for your kind of service. He has a thousand countries like Algeria. There is no difference [for him] whether Algeria exists or not. From now on, you are not allowed to approach the Ottoman shores
The janissaries then begged for a vali which was finally sent years after, however it should be clear that the Ottomans for the most part just let the North African provinces to generally do as they pleases
Fast forward to the 1820s, the Ottoman Empire were in a crisis. The Greeks had risen up in revolt, Muhammad Ali had started to consolidate his power, and the war with Russia is lost even with fierce resistance from Ottoman troops. So when the French invaded Algeria, there's little they can do except lodge a protest; A war with France would surely end in a disaster. However, they are aware of French colonial ambition and try to salvage what remained of their North African territories. They send an army which quickly defeated the Karamanli dynasty in Tripoli and by the 1840s, the Ottomans had secured Libya. It's during this time that the Ottomans also struck a political cooperation with the Sanussis. The Algerians also fought back, notably Ahmed Bey in Constantine, Abd al-Qadir in Western Algeria, and Muhammad ben Abdallah in Dahra, which would only be pacified in the 1850s
With Ottoman reoccupation of Libya, the Husaynid dynasty of Tunisia is stuck in the difficult position sandwiched between the French, who clearly had designs on the country, and the Ottomans, who sought to draw Tunisia back into their fold as a loyal province. The Tunisians for some time agreed to be an Ottoman "protectorate" but this was never fully realized. The Congress of Berlin of 1878 placed Tunisia in the French political sphere of influence because of their monetary difficulties, and by 1881 the French had invaded Tunisia, with the excuse of stopping raids and to protect both the Husaynid Dynasty’s rule and regional stability. The French occupiers allowed the Husaynid dynasty to maintain the facade that it was still in control, but it was the French rather than the Ottomans who were the country’s "protectors". Dealing with Balkan losses and with Tunisia under French sphere, The Ottomans can't do anything except lodged a protest, but they send troops to Libya to consolidate the only African province under direct Ottoman control. The French protested this move but the Porte cheekily responded that it was only trying to ensure security and stability in Tripolitania, which would benefit French interests as well. Ferik Zeki Pasha, a divisional general in the Ottoman army urged the Porte to pay closer attention to Libya and urged the sultan to leave the Balkan losses behind and focus on North Africa, something that the Porte especially Sultan Abdülhamid II took to heart
When the Ottomans attended the Conference of Berlin in 1884, It was a bid to re-enter the rank of expansionist empires and to claim lands well beyond Ottoman Libya, in particular the Sahara and Lake Chad Basin. By signing the act, Ottoman right to the Mediterranean coast of Tripolitania and Cyrenaica was acknowledged by other participants in the conference, but on the other hand, by agreeing to the new rules it recognized the right of France to Algeria and Tunisia. This was something they would regret as the game of diplomacy clearly put the Ottomans at the disadvantage, with European powers disregarding the act of Berlin and Ottoman claims. Even the Libyan provinces, the last of the Ottoman provinces in Africa which was supposed to be guaranteed by European powers, were now on the table as targets of European colonial occupation. With the African colonial project being an utter failure and European imperial projects to Libya becoming even clearer, the Ottomans changed their relationship with the Sanussis of Libya from political cooperation to covert military alliance. The Ottomans started to smuggle weapons to support Sanussi-led resistance in Central Africa and consolidated of its hold on the frontiers of the Libyan provinces. The Sanussis, armed by the Ottomans would fight the French in Fashoda, Derna, and Darfur. The Ottomans meanwhile had lost faith in international agreements and thus Ottomans pursuit a strictly independent and isolationist approach to ensure the security of its domains. This is why the Ottomans had fiercely defended Libya, it was the last Ottoman African province which the Ottomans determined to defend after the failure of diplomacy in the 1880s. During the Italo-Turkish war, Ottoman officers believed they are close to beating the Italians, and the officers protested on why the empire had given up after so many successful engagements by their local soldiers and allies. Determined to regain Libya, The CUP regime decided to establish a sound base for keeping the insurgency alive in hopes of restarting the war after the end of Balkan crisis. Some officers and other ranks (overall 300 personnel) were selected to remain, and nearly all the heavy weapons and ammunition were left behind. Selected local NCOs and soldiers were passed through an intense military technical training in order to operate the heavy weapons and various devices. As a part of this scheme, more than 100 young Libyan students were transferred to military schools in Istanbul for the training of the next generation of leaders and officers, who would lead the next war. Unfortunately for the empire, this bold scheme fell victim to the Balkan defeats and was only partially realized during the First World War
Sources:
The Ottoman Scramble of Africa by Mostafa Minawi
The Arabs of The Ottoman Empire, 1516-1918 by Bruce Masters
A Military History of the Ottomans by Mesut Uyar
The Ottoman World by Christine Woodhead for the Algerian letter