In a large skillet over medium heat, melt butter. Add onions and salt and cook, stirring occasionally, until onions are jammy and deep golden brown, 35 to 50 minutes.
Add thyme and wine and cook, stirring and scraping up bits from bottom of pan, until liquid is reduced and onions are jammy, 1 to 2 minutes. Let cool slightly.
Make Ahead: Onions can be caramelized 3 days ahead. Let cool, then transfer to an airtight container and refrigerate. Return to room temperature before using.
On a clean surface, arrange bread slices in a single layer. Spread butter on top of each slice of bread. Flip 4 slices buttered side down, then top with caramelized onions; season with pepper. Sprinkle with thyme. Arrange 1 ounce Gruyère on top of onions. Close with remaining bread slices buttered side up.
Preheat a large nonstick skillet over medium heat. Add 2 sandwiches, arranging cheese side closest to pan, and cook until golden brown, 2 to 3 minutes. Flip and continue to cook until golden brown on the other side and cheese is melty, 2 to 3 minutes more. Transfer sandwiches to a plate. Repeat with remaining sandwiches. Serve warm.
